Introduction to Objects MIS 3501: Management Information Systems Paul Weinberg weinberg@temple.edu Adapted from material by David Schuff, and Paul Weinberg Complex technology projects are difficult to manage and often fail Complex projects are difficult to manage and frequently fail The problem is most frequently handled by breaking the project into small pieces. (Decomposition) Decomposition is used when analyzing a business but also when developing systems. There are two primary methods of decomposition Decomposition Process decomposition Processes are made up of smaller processes, which are made up of smaller processes, etc. Visualized in class through Data Flow Diagrams (DFDs) and flowcharts Component (or object) decomposition Objects are collections of processes and data associated with the processes Visualized through the Universal Modeling Language (UML) How decomposition is used Each piece can be developed independently by separate teams. The pieces are tested independently (unit testing), and then assembled to test larger units (system testing). The assembly process continues until the entire system is ready to be tested by the user (acceptance testing). Process vs Component (Object) Decomposition Process Processes executed in order following a process flow. Processes use subprocesses at defined points. Normally the operation of a subprocess is not hidden from the outside world. Component Processes executed when a component receives a message from another component Processes can be executed when an event occurs Normally the operations of a component are hidden from the outside world. There is a mechanism for creating families of standardized components Process vs Component (Object Decomposition) Process To use a process you need to know the items in a DFD Component • The messages to send to the component • The messages it returns • What it does • Input • Output • What it does There is no mechanism for standardizing groups of processes Generally organized in a hierarchy To use a component, you need to know There is a mechanism for creating families of standard components assuring that they all operate in a similar fashion Generally organized by use. (Which components use other components) Decomposition Examples Process IRS forms Cookbooks Traditional (green screen) computer applications Component Airline reservation systems Windows applications and visual components Company franchises Service applications (like ATM networks) Personal Computer and TV construction Methods and Objects Methods are mechanisms for implementing systems through process decomposition. Software objects are mechanisms for implementing systems by breaking them into components. Most modern programming languages are objectoriented • Java, C++, C#, etc. You have been using objects in this course . . . TextBox Class txtIncome Object txtTax Object Properties Text Location ReadOnly Size 900 123,83 false 100,20 $18.00 123,120 true 100,20 Methods Hide() Show() Paste() Using Object Technology Create or obtain object classes An object class is a template (or pattern) from which an object is created Create (instantiate) one or more objects from the class Assemble the objects if necessary into larger objects Use the objects Objects in computer programs are collections of data and procedures o The procedures affect the data and determine what the object does o The data items in an object are sometimes called properties o The procedures may be called functions or methods. o Functions and methods may respond to events Real World Objects - McDonalds Class Definition McDonalds Standards: Properties and data Grill specifications Financial goals General ledger reporting data Bread inventory Methods Cook a Big Mac Keep a Big Mac warm Set financial goals Report monthly financials Standards, processes, and structure Shinjuku Station, Tokyo, McDonalds 30th Street Station, Philadelphia, McDonalds Objects The McDonalds Example Encapsulation McDonalds Parent Monthly Financial results 30th Street Station, Philadelphia, McDonalds [local records] Shinjuku Station, Tokyo, McDonalds [local records] Object-Oriented Design Account Object name: Encapsulation Object Hierarchies Inheritance Polymorphism Object attributes/properties: Object functions/methods: Number Beginning Balance Name Ending Balance Client Current Balance Manager Interest Rate Date Opened Open Acct Close Acct Accept Deposits Withdrawal Pay Interest Savings Interest Rate Monthly Fees Checking Lowest Balance in Month Bad Check Charges Authorized Signature Pay Interest Compute Charges Print Quarterly Statement Budget Saver Print Monthly Statement Send Bad Check Notice Pay Interest Money Market Volume Senior Citizen CD Fixed Fee Student So far . . . We have used pre-defined classes which generate visible objects Forms Buttons TextBoxes ListBoxes The objects are created for you when you drag the class name to the design area from the toolbox. Some of the objects contain other objects (Forms contain Buttons, TextBoxes, etc) You use the objects following the object name with the property or method. For example: txtTax.Text txtTax.hide() New concepts Creating classes Classes which create non-visible objects Accounts Airline Reservations Later: Objects in Arrays and ArrayLists Classes which inherit from other other classes. Alice Exercise Alice is a programming system from Carnegie Mellon University for creating interactive 3-D worlds Alice was develop to introduce people to object technology. Examples of classes in Alice include: People, buildings, vehicles, animals Alice Objects created from Alice classes have properties and methods If you want to know more about Alice . . . You can get your own (free) copy at www.alice.org A book is available but not required for this course . . . • Learning to Program with Alice (Wanda Dunn, Stephen Cooper, Randy Pausch) --- Pearson, Prentice Hall Free tutorials are available at www.dickbaldwin.com/tocalice.htm and other sites.