This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: EECS 280 Week 9 Discussion Notes Introduction to Object Oriented Programming: Classes 1 Prologue After reading, rereading and carefully analyzing the specification document the entire morning, you feel eager to start your new assignment–a back-end system for handling BankTwo’s financial transactions. However, before you can begin, you needed to know the implementation details for date data (you made a note of that along with many other things while reading the spec). The project had been divided and assigned to two teams, the date structure was the other team’s responsibility. You slowly walk across the hall wondering to yourself, “why would they assign three pro- grammers for the other team, while I have to work alone on the more complicated part. I guess a flashy user interface is more important than any security concerns. I know where I won’t be opening an account...” Alice who saw you coming, gave a courtesy smile and asked, “how may I help you?” “Yeah, you see I need to know how you plan to implement the date thing, so I can get started,” you say, getting straight to the point. “Well, we are trying to decide on that.” Alice says, “maybe you can help us decide. You see I think we should store the date as a string, straight from the user’s input, we can manipulate it later depending on the specific use, plus outputting will be super easy. However, Bob thinks we should store it as an integer representing the number of days since Jan 1st, 1970, which would make comparison, and duration calculations easy, but requires more work converting to/from string form. Chris had a hybrid approach, storing the data as three integers day/month/year. What do you think?” 2 Object-oriented Programming Wake up! It’s the 21st century, Object-oriented Programming (OOP) is here. Knowing the OOP style will help you avoid such trouble. But what is OOP? Object-oriented programming (OOP) is a programming paradigm that uses “ob- jects” and their interactions to design applications and computer programs. It is based on several techniques, including encapsulation, modularity, polymorphism, and inheritance.-Source Wikipedia So OOP is not a programming language, but a programming style or principle. The goal is to break software into more fundamental units, while increasing maintainability (the ease of fixing/modifying a program) and re-usability (the ability to reuse common components in other software). Let’s discuss the various principles in OOP. Encapsulation (aka information hiding) is the principle that the user only needs to know how to manipulate the object, and does not need to know how the object is actually stored, 1 or how each action is implemented. So the user is protected from any implementation changes in the object (and you can just say to Alice, “I don’t care how you implement it, just give me the interface!”) Modularity is a concept that encourages breaking the task into fundamental blocks, and facilitates reusing code, and code maintenance (i.e. fixing/modifying the program). Thefacilitates reusing code, and code maintenance (i....
View Full Document
- Winter '08
- Object-Oriented Programming, derived class