What's the difference between public, private, and protected?

A member (either data member or member function) declared in a private section of a class can only be accessed by member functions and friends of that class A member (either data member or member function) declared in a protected section of a class can only be accessed by member functions and friends of that class, and by member functions and friends of derived classes A member (either data member or member function) declared in a public section of a class can be accessed by anyone

How can I protect derived classes from breaking when I change the internal parts of the base class?
A class has two distinct interfaces for two distinct sets of clients:
• •

It has a public interface that serves unrelated classes It has a protected interface that serves derived classes

Unless you expect all your derived classes to be built by your own team, you should declare your base class's data members as private and use protected inline access functions by which derived classes will access the private data in the base class. This way the private data declarations can change, but the derived class's code won't break (unless you change the protected access functions). •
Access control of base class members (C++ only) When you declare a derived class, an access specifier can precede each base class in the base list of the derived class. This does not alter the access attributes of the individual members of a base class as seen by the base class, but allows the derived class to restrict the access control of the members of a base class. You can derive classes using any of the three access specifiers:

• • •

In a public base class, public and protected members of the base class remain public and protected members of the derived class. In a protected base class, public and protected members of the base class are protected members of the derived class. In a private base class, public and protected members of the base class become private members of the derived class.

In all cases, private members of the base class remain private. Private members of the base class cannot be used by the derived class unless friend declarations within the base class explicitly grant access to them. In the following example, class d is derived publicly from class b. Class b is declared a public base class by this declaration. class b { }; class d : public b // public derivation { }; You can use both a structure and a class as base classes in the base list of a derived class declaration:

• •

If the derived class is declared with the keyword class, the default access specifier in its base list specifiers is private. If the derived class is declared with the keyword struct, the default access specifier in its base list specifiers is public.

In the following example, private derivation is used by default because no access specifier is used in the base list and the derived class is declared with the keyword class:

struct B { }; class D : B // private derivation { }; Members and friends of a class can implicitly convert a pointer to an object of that class to a pointer to either: • • A direct private base class A protected base class (either direct or indirect)

Description: Normally in multi-winform application we create a common base class which exhibits common behavior of all forms in application. Every win-form deriving from common base win-form will have same behavior as of base win-form. Implementing base-derived model in WPF is a bit complex because both Xaml and code behind (.cs) class should know which base class to derive from. Let's implement this model in WPF using one practical scenario: Example: Suppose we want that every WPF dialog used in our application should be a modal dialog. So our motive is to create a base class which will ensure every dialog deriving from this base class will be modal dialog. Implementation Approach: Step 1: Create a base class which exposes one public method ShowModalDialog() which associates WPF window to main window. Any class deriving from this base class will call this exposed method instead of normal ShowDialog () method to show modal dialog. public class DialogBase: Window { [DllImport("user32.dll")] iternal static extern IntPtr GetActiveWindow (); window reference.


• •


• • •

// Returns active


• • • •

• • •
• •

public bool? ShowModalDialog() { WindowInteropHelper helper = new WindowInteropHelper(this); helper.Owner = GetActiveWindow(); // Set main active window. return this.ShowDialog(); } } Step 2: Now any new wpf window needs to derive from above base class. public class SampleDialog : DialogBase { public SampleDialog( )


• • • •

{ } } Step 3: As any WPF dialog also has a xaml associated with it. So we need to have reference of base class in xaml also so that it can associate with base class. <my:DialogBase xmlns:my="clr-namespace:MyNameSpace" // Include namespace of base class. Title="Sample WPF Dialog" //// Implementation of xaml binding and other stuff as such. </my:DialogBase> Step4: Now we have the basic framework available and we are ready to use it while showing WPF dialog. Instead of calling showDialog() method we will call base class’s ShowModalDialog() method. Main() { SampleDialog wpfDialog = new SampleDialog (); wpfDialog.ShowModalDialog(); }

• • • • •


• •
• •


• Derived Classes

C++ allows you to use one class declaration, known as a base class, as the basis for the declaration of a second class, known as a derived class. Suppose you had a class called CPushButton that implemented a simple push-button, like the one shown in Figure 1.


• Figure 1. Simple push-button. The CPushButton class definition might look something like this:

• • • • • • • • • • • • • •

/* 1 */ class CPushButton { protected: Rect bounds; Str255 title; BooleanisDefault; WindowPtrowningWindow; ControlHandle buttonControl; public: CPushButton( WindowPtr owningWindow, Rect *bounds, Str255 title, Boolean isDefault ); virtual~CPushButton();

Here’s what this means. you might create a CPictureButton class that creates a push button with a picture instead of a text label. We’ll get to it in a bit. For example. Boolean isDefault ). For example. virtual void Draw(). }. Notice that they were declared using the protected access specifier. if you defined an object in main() that featured a private data member. telling you that you are trying to access a member inappropriately. In addition. • Deriving One Class From Another • • Why would you want to derive one class from another? You might want to extend the functionality of a class. protected is very similar to the private access specifier. but never by an outside function like main(). or customize it in some way. For example. Take a look at the CPushButton data members. The first line tells you that this class is derived from the CPushButton class. but referring to the data member within main() will cause a compile error. By basing the CPictureButton class on CPushButton. the bounds data member might be accessed by the CPushButton classes’ Draw() function. space is allocated for the CPictureButton data member. A member marked as protected is accessible from member functions of the class and also from member functions of any classes derived from that class. A data member or member function marked as private is only accessible from within member functions of that class. This means that a CPictureButton member function can refer to both CPictureButton and CPushButton data members. DoClick(). referring to the data member within a member function works just fine.• • • • • virtual void virtual void }. a protected member is also accessible from the member functions of any classes derived from its class. Draw(). ignore the keyword virtual that’s sprinkled throughout the CPushButton class definition. • • For the moment. virtual void DoClick(). you automatically inherit all of CPushButton data members and member functions. as well as for all of the non-private CPushButton data members. virtual~CPushButton(). When you create a CPushButton object. public: CPictureButton( WindowPtr owningWindow. . Every CPictureButton object you create will inherit all the CPushButton member functions and data members. Rect *bounds. Here’s a CPictureButton definition: • • • /* 3 */ CPictureButton *myPictureButton. PicHandle pic. Here’s my definition of a CPictureButton class: • • • • • • • • • • • • • • /* 2 */ class CPictureButton : public CPushButton { protected: PicHandlepic.

If the base class was defined using class. Access to member functions follow the same rules as access to data members. then try to reference it from the class derived from CGramps. which were provided courtesy of CPushButton. from both CPictureButton and CPushButton. To prove this yourself. A myPictureButton member function might refer to pic. If you declared a third class based on CPictureButton. . As this programming is based on objects. the compiler won’t let you access inherited private members. otherwise you won’t have the access you need to create your object! In the definition of the CPictureButton class above. and private members are not inherited at all. which is a CPictureButton data member. be sure you at least mark your constructor and destructor as public. • • REUSABILITY CONCEPT • Object oriented programming is the most preferred programming technique now a day only due to the flexibility of re usability. Object is actually a collection of data and functions that are used to operate on that data. you may have noticed the public keyword on the first line: • • • • • • • • class CPictureButton : public CPushButton This keyword tells the compiler how the members of the base class are accessed by the derived class. My preference is to use class to define all my classes and to use the public keyword in my derived class definitions. You don’t have to include the access keyword. add a private data member to the CGramps class in this month’s program. All it needed were the members that provided what wasn’t already provided by its base class. the CPictureButton class didn’t need to define the data members that gave it its infrastructure. true ). Why non-private? Though your derived class does inherit all of the base class members. the new class would inherit the members all the way up the inheritance chain. These objects are defined as independent entities because the data inside each object represents the attributes of object and functions are used to change these attributes as required by a program. The point here is.• • • • myPictureButton = new CPictureButton(myWindow. If for some reason you don’t want to mark your member functions as public. or perhaps bounds or owningWindow. Re usability is actually an attribute that makes the object oriented programming more flexible and attractive. which is CPops. In the previous code. The public keyword says that public members from the base class are public in the derived class. If the base class was defined using struct. public and protected members from the base class are private in the derived class. the derivation defaults to public. &buttonRect. the CPictureButton member functions can access all of the non-private CPushButton member functions. myPicture. and private members are not accessible at all. If the private keyword is used. My general strategy is to mark my member functions as public and my data members as protected. the derivation defaults to private. protected members from the base class are protected in the derived class.

class A { public virtual void { func1() Console. It means that if we require some new object that also needs some functionality of existing one's then it is easy to inherit the existing one instead of writing all the required code once again. and afterward they can be used in any other program that needs the same functionality. rather they can be used in more than one application as required. These objects are defined as an independent entity in a program. Thus. } } static void A Main(string[] args) { a new B(). new objects are defined that inherit the existing objects and provide extended functionality as required. This reuse of objects helps in reducing the development time of programs.In inheritance. } a.Write("Base function2").These objects act just like spare parts of any program. .func1(). This reuse also plays a basic role in inheritance that is a characteristic of object oriented programming. they are not limited to any specific program.Write("Base function1"). } } class B { : A public override void { func1() Console. what is the use of procedure overriding To supress the base class virtual method and wanted derived method to be called then Base class virtual method is overrided in the derived class.

search An object database (also object-oriented database) is a database model in which information is represented in the form of objects as used in object-oriented programming. the abstract superclass defines a common interface which all the subclasses inherit. for example. Thus. whereas the former does not require a parameter. Method overloading is a feature found in various programming languages such as Ada. For example. doTask() and doTask(object O) are overloaded methods. and the correct function call again. To call the latter. is a language feature that allows a subclass to provide a specific implementation of a method that is already provided by one of its superclasses. Such abstract classes have methods that do not perform any useful operations and are meant to be overridden by specific implementations in the subclasses. you are really just making a number of different methods that happen to have the same name. the free encyclopedia Jump to: navigation. A subclass can give its own definition of methods which also happen to have the same signature as the method in its superclass. Object database From Wikipedia. as some languages support covariance on return types. abstract classes are designed — i. Print(image_object P).Method overriding. If we write the overloaded print methods for all objects our program will "print". C#. Method overriding is an important feature that facilitates polymorphism in the design of objectoriented programs. This means that the subclass's method has the same name and parameter list as the superclass's overridden method. text or pictures. In this case one might like the method to be different when printing. and is called with an empty parameter field. Constraints on the similarity of return type vary from language to language. D and Java that allows the creation of several methods with the same name which differ from each other in terms of the type of the input and the type of the output of the function. the call is always: Print(something). A common error would be to assign a default value to the object in the second method. The implementation in the subclass overrides (replaces) the implementation in the superclass. Some languages allow the programmer to prevent a method from being overridden. . When overloading a method. an object must be passed as a parameter. In many cases. This may or may not involve an inability to subclass from a given class. Another example would be a Print(object O) method. as the compiler wouldn't know which of the two methods to use. which would result in an ambiguous call error. classes that exist only in order to have specialized subclasses derived from them. or disallow method overriding in certain core classes. The two different methods may be overloaded as Print(text_object T). C+ +. It is resolved at compile time which of these methods are used. in object oriented programming. Method overloading is usually associated with statically-typed programming languages which enforce type checking in function calls.e. we never have to worry about the type of the object.

graphs. store them as objects. and can replicate or modify existing objects to make new objects within the OODBMS. and photos which are considered complex data types. Contents [hide] • • • • • • • • • 1 Overview 2 History 3 Adoption of object databases 4 Technical features 5 Standards 6 Advantages and disadvantages 7 See also 8 References 9 External links [edit] Overview When database capabilities are combined with object-oriented (OO) programming language capabilities. Today’s trend in programming languages is to utilize objects.Example of an object-oriented model. By . the result is an object database management system (ODBMS). though there is some usage in specialized areas. audio. Object databases have been considered since the early 1980s and 1990s but they have made little impact on mainstream commercial data processing. Relational DBMS aren’t natively capable of supporting these complex data types. Information today includes not only data but video. thereby making OODBMS ideal for OO programmers because they can develop the product.[1] Object databases are a niche field within the broader DBMS market dominated by relational database management systems (RDBMS).

available under dual open source and commercial licensing. and Vbase (Ontologic). C#.being integrated with the programming language. Starting in 2004. O2[5] (O2 Technology.[4] Early commercial products included Gemstone (Servio Logic. POET (now FastObjects from Versant which acquired Poet Software). Vbase (COP) and VOSS (Virtual Object Storage System for Smalltalk).). [edit] History Object database management systems grew out of research during the early to mid-1970s into having intrinsic database management support for graph-structured objects. ObjectStore (Progress Software. name changed to GemStone Systems). Perl. acquired from eXcelon which was originally Object Design). The ORION project had more published papers than any of the other efforts. Gbase (Graphael). The term "objectoriented database system" first appeared around 1985. . Matisse (Matisse Software). Visual Basic . Inc. object databases have seen a second growth period when open source object databases emerged that were widely affordable and easy to use. Object database management systems added the concept of persistence to object programming languages. Some of these products remain on the market and have been joined by new open source and commercial products such as InterSystems CACHÉ (see the product listings below). ONTOS (Ontos. IRIS (Hewlett-Packard). Relational DBMS projects using complex data types would have to be divided into two separate tasks: the database model and the application. Jasmine (Fujitsu. Vodak (GMD-IPSI). companies have a vested interest in OODBMS to display their complex data. the programmer can maintain consistency within one environment because both the OODBMS and the programming language will use the same model of representation. Versant Object Database (Versant Corporation).[3] Notable research projects included Encore-Ob/Server (Brown University). and Zeitgeist (Texas Instruments). acquired by Informix. For much of the 1990s. ODBMSs use exactly the same model as object-oriented programming languages. VOSS (Logic Arts) and JADE (Jade Software Corporation). EXODUS (University of Wisconsin–Madison). merged with several companies. ORION (Microelectronics and Computer Technology Corporation or MCC). which was in turn acquired by IBM). because they are entirely written in OOP languages like Smalltalk.. others have their own programming languages. marketed by Computer Associates). Gbase (LISP).NET. C++. Some object-oriented databases are designed to work well with object-oriented programming languages such as Ruby. Java or C#. Inc. C#. Objectivity/DB (Objectivity. DTS/S1 from Obsidian Dynamics and Perst (McObject). C++ dominated the commercial object database management market. ODE (Bell Labs). name changed from Ontologic). Using a DBMS that has been specifically designed to store data as objects gives an advantage to those companies that are geared towards multimedia presentation or organizations that utilize computer-aided design (CAD)[2]. Vendors added Java in the late 1990s and more recently. Won Kim of MCC compiled the best of those papers in a book published by The MIT Press. As the usage of web-based technology increases with the implementation of Intranets and extranets. The early to mid-1990s saw additional commercial products enter the market. These included ITASCA (Itasca Systems). Java. The early commercial products were integrated with various languages: GemStone (Smalltalk). Python. such as db4o (db4objects). Objective-C and Smalltalk.

Access to data can be faster because joins are often not needed (as in a tabular implementation of a relational database). [edit] Technical features Most object databases also offer some kind of query language. most of the major object database and object-relational mapping vendors claimed conformance to the ODMG Java Language Binding. Also. An object can be viewed as the set of all its versions. Multimedia applications are facilitated because the class methods associated with the data are responsible for its correct interpretation.0. They have made little impact on mainstream commercial data processing. however. Some object databases also provide systematic support for triggers and constraints which are the basis of active databases. Many object databases. In 2001. It published several versions of its specification. telecommunications. A general characteristic. The last release was ODMG 3. be argued that "joining" is a higher-level abstraction of pointer following. The efficiency of such a database is also greatly improved in areas which demand massive amounts of data about one item. The Big O Notation for such a database paradigm drops from O(n) to O(1). is that the programming language and the database schema use the same type definitions. For example. and real-time systems. that the biggest differences between products are found. however. and the integration of the query and navigational interfaces. (It could. Compliance to the other components of the specification was mixed. An attempt at standardization was made by the ODMG with the Object Query Language. By 2001. object versions can be treated as objects in their own right. the ODMG Java Language . a banking institution could get the user's account information and provide them efficiently with extensive information such as transactions. by following pointers. members of the academic community. though there is some usage in specialized areas of financial services. OQL. and interested parties. Another group of object databases focuses on embedded use in devices. [edit] Standards The Object Data Management Group (ODMG) was a consortium of object database and objectrelational mapping vendors.) Another area of variation between products is in the way that the schema of a database is defined. for example VOSS. and scientific areas such as high energy physics and molecular biology. This is because an object can be retrieved directly without a search. allowing objects to be found by a more declarative programming approach.[6] It is also worth noting that object databases held the record for the World's largest database (being the first to hold over 1000 terabytes at Stanford Linear Accelerator Center)[7] and the highest ingest rate ever recorded for a commercial database at over one Terabyte per hour. offer support for versioning. It is in the area of object query languages. account information entries etc. Its goal was to create a set of specifications that would allow for portable applications that store objects in database management systems. packaged software. greatly increasing efficiency in these specific cases.[edit] Adoption of object databases Object databases based on persistent programming acquired a niche in application areas such as engineering and spatial databases.

and data formats (e. Benchmarks between ODBMSs and RDBMSs have shown that an ODBMS can be clearly superior for certain kinds of tasks. Java and . XQuery has enabled a new class of applications that managed hierarchical data built around the XRX web application architecture that also provide many of the advantages of object databases. Objects have a many to many relationship and are accessed by the use of pointers. Another benefit of OODBMS is that it can be programmed with small procedural differences without affecting the entire system[9]. for general-purpose . to provide close. Similarly..g.NET. In addition XRX applications benefit by transporting XML directly to client applications such as XForms without changing data structures. The ODMG member companies then decided to concentrate their efforts on the Java Data Objects specification.g. Native Queries emerged. As a result. XML) and to include new features into these standards that support domains where object databases are being adopted (e. This ability to change relationships leads to another benefit which is that relational DBMS can’t handle complex data models while OODBMS can.g. Pointers are linked to objects to establish relationships. Rai..g. the ODMG disbanded in 2001. Please improve it by verifying the claims made and adding references. language-integrated database query capabilities with its programming languages C# and VB. spatial indexing). Many object database ideas were also absorbed into SQL:1999 and have been implemented in varying degrees in object-relational database products.. data management (e. [edit] Advantages and disadvantages This section may contain original research. Statements consisting only of original research may be removed.. and Rosenberger proposed to drop all standardization efforts to introduce additional object-oriented query APIs but rather use the OO programming language itself. This is most helpful for those organizations that have data relationships that aren’t entirely clear or need to change these relations to satisfy the new business requirements. an implementation of LINQ. real-time systems). In 2005 Cook. replication).0 specification and the formation of the Object Database Technology Working Group (ODBT WG). Microsoft announced Language Integrated Query (LINQ) and DLINQ. (October 2008) The main benefit of creating a database with objects as data is speed. The main reason for this is that many operations are performed using navigational rather than declarative interfaces. The ODBT WG plans to create a set of standards that incorporates advances in object database technology (e. and navigational access to data is usually implemented very efficiently by following pointers. i.. More details may be available on the talk page. in September 2005.Binding was submitted to the Java Community Process as a basis for the Java Data Objects specification. the Object Management Group (OMG) announced that they had been granted the right to develop new specifications based on the ODMG 3.NET 9. to express queries.e. Critics of navigational database-based technologies like ODBMS suggest that pointer-based techniques are optimized for very specific "search routes" or viewpoints. In February 2006. OODBMS are faster than relational DBMS because data isn’t stored in relational rows and columns but as objects[8]. As a result. On January 2007 the World Wide Web Consortium gave final recommendation status to the XQuery language.

this objection is offset by the fact that some ODBMSs fully support SQL in addition to navigational access. pointer-based techniques will tend to be slower and more difficult to formulate than relational. navigation appears to simplify specific known uses at the expense of general.queries on the same information. maintaining entity-identity independently of changing attributes. In addition it supports some important concepts and terminology which has made it popular among programming methodology. which allows a query to 'drill down' into complex data structures.[citation needed] Features of Object oriented Programming The Objects Oriented programming language supports all the features of normal programming languages. The important features of Object Oriented programming are: • • • • • • Inheritance Polymorphism Data Hiding Encapsulation Overloading Reusability Let us see a brief overview of these important features of Object Oriented programming But before that it is important to know some new terminologies used in Object Oriented programming namely . and InterSystems CACHÉ. allowing both kinds of access. with suitable language support. and the assumption underlying much database technology. Other things that work against ODBMS seem to be the lack of interoperability with a great number of tools/features that are taken for granted in the SQL world. rather than only on attribute value.g. unforeseen. the essential arguments in its favor remain valid. and varied future uses. a persistent language may index aggregations on whatever its content elements return from a call to some arbitrary object access method. including but not limited to industry standard connectivity. Database-centric thinking tends to view the world through a declarative and attribute-driven viewpoint. indexed aggregations. Matisse. Effective use may require compromises to keep both paradigms in sync. unlike the relational model. while OOP tends to view the world through a behavioral viewpoint. [citation needed] Additionally. Although some commentators have written off object database technology as a failure. e. furthermore. which is that data should be accessible to queries based on data content rather than predefined access paths. and attempts to integrate database functionality more closely into object programming languages continue in both the research and the industrial communities. reporting tools. In fact there is an intrinsic tension between the notion of encapsulation. OLAP tools. which hides data and makes it available only through a published set of interface methods. direct object references may be maintained in addition to normalised. Objectivity/SQL++. However. object databases lack a formal mathematical foundation. Thus. and backup and recovery standards. and this in turn leads to weaknesses in their query support.[citation needed] However. This is one of the many impedance mismatch issues surrounding OOP and databases.

} In other words classes acts as data types for objects. This is done by declaring data as private and making it accessible only to the class in which it is defined. Memory is occupied only by object. The data is hidden inside the class by declaring it as private inside the class. .• • Objects Classes Objects: In other words object is an instance of a class.. Member functions: The functions defined inside the class as above are called member functions. Example: Class classname { Data Functions }. But one can keep member functions as public.. When data or functions are defined as private it can be accessed only by the class in which it is defined.. Here the concept of Data Hiding figures Data Hiding: This concept is the main heart of an Object oriented programming. In other words class is a collection of similar objects. main ( ) { classname objectname1. When we define a class it just creates template or Skelton. When data or functions are defined as public then it can be accessed anywhere outside the class.objectname2. Classes: These contain data and functions bundled together under a unit. Object Oriented programming gives importance to protecting data which in any system. This concept is called data hiding. So no memory is created when class is created.

. So those features can be placed in a common tree class called base class and the other classes which have these charaterisics can take the tree class and define only the new things that they have on their own in their classes. . This provide the users the important usage of terminology called as reusability Reusability: This usage is achieved by the above explained terminology called as inheritance. It is very much needed for any programmers in different situations. main ( ) { classname objectname1. Inheritance: Inheritance as the name suggests is the concept of inheriting or deriving properties of an exiting class to get new class or classes. Reusability gives the following advantages to users It helps in reducing the code size since classes can be just derived from existing one and one need to add only the new features and it helps users to save their time.. } Encapsulation: The technical term for combining data and functions together as a bundle is encapsulation. public: Member functions }. The main advantage of using this concept of inheritance in Object oriented programming is it helps in reducing the code size since the common characteristic is placed separately called as base class and it is just referred in the derived class.So above class structure becomes Example: Class classname { private: datatype data.. These classes are called derived class.objectname2. In other words we may have common features or characteristics that may be needed by number of classes. Reusability is nothing but re.usage of structure without changing the existing one but adding new features or characteristics to it.

Java will be the language used to implement the concepts in code. . So Polymorphism as the name suggests is a certain item appearing in different forms or ways. Of course. but they are a great place to start a discussion. these are not the only important terms. We will also begin to get much more involved with code. Remember that there are three criteria that are applied to object-oriented languages: They have to implement encapsulation. . Click here to start at the beginning of the series. In this scenario instead of defining a class to draw a graphical figure and coloring it what the user can do is make use of the existing class for drawing graphical figure by deriving the class and add new feature to the derived class namely add the feature of adding colors to the graphical figure. In other words say for instance we know that +. this article. That is making a function or operator to act in different forms depending on the place they are present is called Polymorphism. The material presented in these articles is based on material from the second edition of my book. we will focus on a single concept and explore how it fits in to the object-oriented model. and polymorphism. Polymorphism and Overloading: Poly refers many. This is a very important feature of object oriented programming methodology which extended the handling of data type and operations. inheritance. Overloading is a kind of polymorphism. The Object-Oriented Thought Process is intended for anyone who needs to understand the basic object-oriented concepts before jumping into the code. Now that we have covered the conceptual basics of classes and objects. The Object-Oriented Thought Process.operate on integer data type and is used to perform arithmetic additions and subtractions. 2004 By Matt Weisfeld Bio » Send Email » More Articles » • • • • Introduction This is the seventh installment in a series of articles about fundamental object-oriented (OO) concepts. In the previous article. But operator overloading is one in which we define new operations to these operators and make them operate on different data types in other words overloading the existing functionality with new one. and several of the ones that follow. 2nd edition. we can start to explore specific concepts in more detail.For instance if there is a class defined to draw different graphical figures say there is a user who want to draw graphical figure and also add the features of adding color to the graphical figure. Hiding Data within Object-Oriented Programming • July 29. In keeping with the code examples used in the previous articles.

class CheckingAccount { private double balance = 0. we created a class diagram that is represented in the following UML diagram. I have the SDK 1. • Figure 1: UML Diagram for Checking Account Class This class is designed to illustrate the concept of encapsulation. }. the attributes. The application that produces this error is shown in Listing 2. .com/. Checking Account Example Recall that in the previous article. This class encapsulates both the data (attributes) and methods (behaviors). not all of the class is accessible to other class.4. We proved in the last article that attempting to access this attribute directly from an application would produce an error. Encapsulation is a fundamental concept of object-oriented design—all objects contain both attributes and behavior. public double getBalance(){ return balance. You can download the J2SE 1. I will provide figures and the output for these examples.0 loaded on my machine.2 SDK (software development kit) to compile and execute these applications and will provide the code listings for all examples in this article. private double balance = 0.sun. } Data Hiding Returning to the actual CheckingAccount example. }.One of the reasons that I like to use Java is because you can download the Java compiler for personal use at the Sun Microsystems Web site http://java. consider again the balance attribute. This class diagram maps directly to the code in Listing 1.4. we can see that while the class contains both attributes and behavior. For example. Note that balance is defined as private. see Figure 1. and the behaviors. The UML class diagram is composed of only three parts: the class name. public void setBalance(double bal) { balance = bal. See the previous article in this series for detailed descriptions for compiling and running all the code examples in this series.

} } Listing 2: Encapsulation. the compiler does not allow this. allows for the attribute to be declared as public.balance = 40.balance = 40.getBalance()).").println("Starting myEncapsulation. public void setBalance(double bal) { balance = bal. you get this protection checking for free. Whereas the class's attributes are hidden. just as C++.00. it fails to set balance to 40 only because the access was declared as private. myAccount.println("Balance = " + myAccount. It is interesting to note that the Java language. . This then would break the object-oriented concept of data hiding and would not be considered a proper object-oriented design..out. If you declare all of a class's attributes as private. a rogue developer cannot directly access the attributes from an application. and other languages. In this case. }. If you abide by the rule that all attributes are private.java The offending line is the where this main application attempts to set balance directly.. public double getBalance(){ return balance.00. }.class Encapsulation { public static void main(String args[]) { System. System. C#. As we saw in last month's article. This line violates the rule of data hiding. however. This is so important because the compiler now can enforce the data hiding rule. CheckingAccount myAccount = new CheckingAccount(). the methods in this example are designated as public. all attributes of an object are hidden. myAccount. Basically. This is one area where the importance of the design comes in.out. the main application would indeed be allowed to directly set the value of balance. thus the term data hiding.

Because an object can only be associated with data in predefined classes or templates.Data hiding is a characteristic of object-oriented programming.. Thus. private. all data not required by an object can be said to be "hidden. protected inheritance? Answe r public: class members are access from the outside the class private: class members can access only within the class protected:class members can access inside the same package . There is no possibility that someone maintaining the code may inadvertently point to or otherwise access the wrong data unintentionally. protected inheritance? Answe r #1 public-->inherite the protected members as preotected in drived class and pubic members wiull be public in derived class protected--->pubic and protecated members of the base class will become protected in derived class Private-->pubilc and proteacted members will become private in derived class 3 Dee Re: What is the difference between public. private. the object can only "know" about the data it needs to know about." What is the difference between public.

since both expressions have exactly the same meaning and behave exactly the same way. but that can be used in the template function as if it were a regular type. In C++ this can be achieved using template parameters. The only difference between both prototypes is the use of either the keyword class or the keyword typename. As you can see. Its use is indistinct. A template parameter is a special kind of parameter that can be used to pass a type as argument: just like regular function parameters can be used to pass values to a function. template parameters allow to pass also types to a function. to call GetMax to compare two integer values of type int we can write: . to create a template function that returns the greater one of two objects we could use: 1 2 3 4 template <class myType> myType GetMax (myType a.Templates Published by Juan Soulie Last update on Nov 16. template <typename identifier> function_declaration. This template parameter represents a type that has not yet been specified. The format for declaring function templates with type parameters is: template <class identifier> function_declaration. These function templates can use these parameters as if they were any other regular type. the function template GetMax returns the greater of two parameters of this still-undefined type. For example. myType b) { return (a>b?a:b). This allows us to create a function template whose functionality can be adapted to more than one type or class without repeating the entire code for each type. } Here we have created a template function with myType as its template parameter. For example. 2007 at 9:36am UTC Function templates Function templates are special functions that can operate with generic types. To use this function template we use the following format for the function call: function_name <type> (parameters).

return 0. n.j). But you can use any identifier you like. we have used T as the template parameter name instead of myType because it is shorter and in fact is a very common template parameter name. template <class T> T GetMax (T a. } int main () { int i=5. result will be an object of the same type as the parameters a and b when the function . m=5. result = (a>b)? a : b. Here is the entire example: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 // function template #include <iostream> using namespace std. n=GetMax<long>(l. This process is automatically performed by the compiler and is invisible to the programmer. T b) { T result. The first time with arguments of type int and the second one with arguments of type long.1 2 int x. cout << k << endl. cout << n << endl. GetMax <int> (x. the type T is used within the GetMax() template function even to declare new objects of that type: T result.m).y. return (result). long l=10. } 6 10 In this case. When the compiler encounters this call to a template function. j=6. k. In the example above we used the function template GetMax() twice. it uses the template to automatically generate a function replacing each appearance of myType by the type passed as the actual template parameter (int in this case) and then calls it. The compiler has instantiated and then called each time the appropriate version of the function. As you can see. k=GetMax<int>(i. Therefore.y).

So we could have written instead: 1 2 int i. This would not be correct. n=GetMax(l. both of this T type. long l=10. k=GetMax(i. we called our function template GetMax() without explicitly specifying the type between angle-brackets <>. cout << k << endl. we cannot call our function template with two objects of different types as arguments: 1 2 3 int i. return 0. and the compiler can automatically find out that the template parameter can only be int. m=5. } int main () { int i=5. template <class T> T GetMax (T a.j). cout << n << endl. Since both i and j are of type int.j). long l.m). This implicit method produces exactly the same result: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 // function template II #include <iostream> using namespace std.j. n. k. since our GetMax function template expects two arguments of the same .l). j=6. T b) { return (a>b?a:b).template is instantiated with a specific type. } 6 10 Notice how in this case. k = GetMax (i. The compiler automatically determines what type is needed on each call. Because our template function includes only one template parameter (class T) and the function template itself accepts two parameters. GetMax (i. In this specific case where the generic type T is used as a parameter for GetMax the compiler can find out automatically which data type has to instantiate without having to explicitly specify it within angle brackets (like we have done before specifying <int> and <long>).

our function template GetMin() accepts two parameters of different types and returns an object of the same type as the first parameter (T) that is passed.type. since the compiler can determine the appropriate instantiation anyway. class U> T GetMin (T a. } }. For example. T second) { values[0]=first. For example. } In this case. after that declaration we could call GetMin() with: 1 2 3 int i. or simply: i = GetMin (j.l). if we wanted to declare an object of this class to store two integer values of type int with the values 115 and 36 we would write: . For example: 1 2 3 4 template <class T. Class templates We also have the possibility to write class templates.l). simply by specifying more template parameters between the angle brackets. For example: 1 2 3 4 5 6 7 8 9 template <class T> class mypair { T values [2]. The class that we have just defined serves to store two elements of any valid type. values[1]=second. We can also define function templates that accept more than one type parameter. public: mypair (T first. even though j and l have different types. long l. so that a class can have members that use template parameters as types. U b) { return (a<b?a:b). and in this call to it we use objects of two different types.long> (j. i = GetMin<int.j.

}.getmax(). b. 2. } 100 Notice the syntax of the definition of member function getmax: 1 2 template <class T> T mypair<T>::getmax () Confused by so many T's? There are three T's in this declaration: The first one is the template . we must always precede that definition with the template <. return 0. 36). this same class would also be used to create an object to store any other type: mypair<double> myfloats (3.. template <class T> T mypair<T>::getmax () { T retval. In case that we define a function member outside the declaration of the class template.0. retval = a>b? a : b. template <class T> class mypair { T a. The only member function in the previous class template has been defined inline within the class declaration itself. return retval. } int main () { mypair <int> myobject (100.mypair<int> myobject (115. T second) {a=first. 75). b=second.18).} T getmax ().> prefix: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 // class templates #include <iostream> using namespace std. cout << myobject.. public: mypair (T first.

return element. // class template specialization: template <> class mycontainer <char> { char element.uppercase() << 8 J . we can declare a specialization of that template. // class template: template <class T> class mycontainer { T element. But we find that when it stores an element of type char it would be more convenient to have a completely different implementation with a function member uppercase.increase() << endl. so we decide to declare a class template specialization for that type: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 // template specialization #include <iostream> using namespace std. cout << mychar. } }. let's suppose that we have a very simple class called mycontainer that can store one element of any type and that it has just one member function called increase.} }.} T increase () {return + +element.parameter. mycontainer<char> mychar ('j'). Template specialization If we want to define a different implementation for a template when a specific type is passed as template parameter. The second T refers to the type returned by the function.} char uppercase () { if ((element>='a')&&(element<='z')) element+='A'-'a'. int main () { mycontainer<int> myint (7). which increases its value. And the third T (the one between angle brackets) is also a requirement: It specifies that this function's template parameter is also the class template parameter. public: mycontainer (char arg) {element=arg. cout << myint. public: mycontainer (T arg) {element=arg. For example.

as described in Cast expressions. The following sections discuss the conversions that are allowed by either implicit or explicit conversion. This is to explicitly declare it as a template specialization... }. because there is no "inheritance" of members from the generic template to the specialization. notice that we precede the class template name with an emptytemplate<> parameter list. and the rules governing type promotions: • • • • • • Arithmetic conversions and promotions Lvalue-to-rvalue conversions Pointer conversions Reference conversions (C++ only) Qualification conversions (C++ only) Function argument conversions . The expression will be converted to a Boolean (or an integer in C89). }. Notice the differences between the generic class template and the specialization: 1 2 template <class T> class mycontainer { .endl. Type conversions An expression of a given type is implicitly converted in the following situations: • • • • The expression is used as an operand of an arithmetic or logical operation. This specialization parameter itself identifies the type for which we are going to declare a template class specialization (char).. template <> class mycontainer <char> { . When we declare specializations for a template class. return 0.. You can perform explicit type conversions using a cast expression. The first line is the generic template.. we must also define all its members. The expression is used as a condition in an if statement or an iteration statement (such as a for loop). even those exactly equal to the generic template class. First of all. ○ A function is provided an argument value that has a different type than the parameter. The expression will be converted to an integral type. But more important than this prefix. This includes the following: ○ An assignment is made to an lvalue that has a different type than the assigned value.. ○ The value specified in the return statement of a function has a different type from the defined return type for the function. and the second one is the specialization. The expression is used in a switch statement. The expression is used as an initialization. } This is the syntax used in the class template specialization: template <> class mycontainer <char> { . }. is the <char> specialization parameter after the class template name.

Let us see this with an example: #include <iostream. . } In the above example the data type short namely variable x is converted to int and is assigned to the integer variable y. So as above it is possible to convert short to int. In other words value gets automatically converted to the specific type in which it is assigned.What is Type Conversion It is the process of converting one type into another. int to float and so on. int y. y=x. Type casting otherwise called as Explicit Conversion Explicit conversion can be done using type cast operator and the general syntax for doing this is datatype (expression).h> void main() { short x=6000. How to achieve this There are two ways of achieving the type conversion namely: Automatic Conversion otherwise called as Implicit Conversion Type casting otherwise called as Explicit Conversion Let us see each of these in detail: Automatic Conversion otherwise called as Implicit Conversion This is not done by any conversions or operators. In other words converting an expression of a given type into another is called type casting.

Here in the above datatype is the type which the programmer wants the expression to gets changed as In C++ the type casting can be done in either of the two ways mentioned below namely: C-style casting C++-style casting The C-style casting takes the synatx as (type) expression This can also be used in C++. Say for instance the as per C-style casting (type) firstVariable * secondVariable is not clear but when a programmer uses the C++ style casting it is much more clearer as below type (firstVariable) * secondVariable Let us see the concept of type casting in C++ with a small example: . Apart from the above the other form of type casting that can be used specifically in C++ programming language namely C++-style casting is as below namely: type (expression) This approach was adopted since it provided more clarity to the C++ programmers rather than the C-style casting.

. often a relational database. type conversion allows programs to treat objects of one type as one of their ancestor types to simplify interacting with them. There are two types of conversion: implicit and explicit.5 type conversion or typecasting refers to changing an entity of one data type into another. The term for implicit type conversion is coercion.[1] However.[2] and have been devised subsequently. In object-oriented programming languages. Explicit type conversion can also be achieved with separately defined conversion routines such as an overloaded object constructor. cin>>a. search A sample Entity-relationship diagram using Chen's notation In software engineering. or ERDs. such as integers. Entity-relationship model From Wikipedia. used to produce a type of conceptual schema or semantic data model of a system. float b.c. Entity-relationship modeling is a database modeling method.h> void main() { int a. cin>>b. variants of the idea existed previously. } The output of the above program is Enter the value of a: 10 Enter the value of b: 12. ER diagrams. cout<<”n The value of c is:”<<c. the free encyclopedia Jump to: navigation. an entity-relationship model (ERM) is an abstract and conceptual representation of data. and its requirements in a top-down fashion. such as division with several decimal places' worth of accuracy.#include <iostream. For instance. cout<< “Enter the value of a:”. values from a more limited set. Diagrams created by this process are called entity-relationship diagrams. can be stored in a more compact format and later converted to a different format enabling operations not previously possible. The most common form of explicit type conversion is known as casting. The definitive reference for entity-relationship modeling is Peter Chen's 1976 paper. cout<< “n Enter the value of b:”. c = float(a)+b. This is done to take advantage of certain features of type hierarchies.

and attributes 3 Diagramming conventions ○ 3. When we speak of an entity we normally speak of some aspect of the real world which can be distinguished from other aspects of the real world. an overview and classifications of used terms and their relationships) for a certain area of interest. the conceptual data model is. at a later stage (usually called logical design). relationships. There are a range of notations employed in logical and physical database design. The data modeling technique can be used to describe any ontology (i.[3] An entity may be a physical object such as a house or a car. such as the relational model. The classical notation mainly relates to conceptual modeling. this in turn is mapped to a physical model during physical design. In the case of the design of an information system that is based on a database. relationships. Although the term entity is the one most commonly used. and attributes Two related entities An entity with an attribute A relationship with an attribute Primary key An entity may be defined as a thing which is recognized as being capable of an independent existence and which can be uniquely identified. mapped to a logical data model. or a concept such as a customer transaction or order. an event such as a house sale or a car service. [edit] The building blocks: entities. such as IDEF1X.1 Crow's Foot Notation 4 ER diagramming tools 5 See also 6 References 7 Further reading 8 External links [edit] Overview The first stage of information system design uses these models during the requirements analysis to describe information needs or the type of information that is to be stored in a database. following Chen we should really distinguish between an entity and an . both of these phases are referred to as "physical design".e. Note that sometimes. There are a number of conventions for entity-relationship diagrams (ERDs). An entity is an abstraction from the complexities of some domain.Contents [hide] • • • • • • • • 1 Overview 2 The building blocks: entities.

a relationship set corresponds to a relation in mathematics. The model's linguistic aspect described above is utilized in the declarative database query language ERROL. Examples: an owns relationship between a company and a computer. by developing an OO system. linking two or more nouns. Rather. In other words. The set of all such child-lunch relationships in a database is a relationship set. is an instance of a given entity-type. The source of the analysis is generally a written requirements statement. Relationships can be thought of as verbs. Entities and relationships can both have attributes. Object-Oriented Design (OOD) is an activity of looking for logical solutions to solve a problem by using encapsulated entities called objects. Relationships are represented as diamonds. most people tend to use the term entity as a synonym for this term. they show entity sets and relationship sets. Every entity (unless it is a weak entity) must have a minimal set of uniquely identifying attributes. a supervises relationship between an employee and a department. a performs relationship between an artist and a song. Examples: a computer. An entity-type is a category. Certain cardinality constraints on relationship sets may be indicated as well. which mimics natural language constructs. Is This Answer Correct ? 20 Yes 3 No 0 Ar ul . A relationship captures how two or more entities are related to one another. Example: a particular song is an entity. the proved relationship may have a date attribute. while a relationship corresponds to a member of the relation. There are usually many instances of an entity-type. Examples: an employee entity might have a Social Security Number (SSN) attribute.entity-type. Attributes are represented as ellipses connected to their owning entity sets by a line. Re: Difference: Object Oriented Analysis (OOA) and Object Oriented Design (OOD)? Answ er #1 Object-Oriented Analysis (OOA) aims to model the problem domain. a mathematical theorem. a proved relationship between a mathematician and a theorem. An entity. a song. The collection of all songs in a database is an entity set. an employee. strictly speaking. Entities are represented as rectangles. Because the term entity-type is somewhat cumbersome. The eaten relationship between a child and her lunch is a single relationship. Entity-relationship diagrams don't show single entities or single instances of relations. Entities can be thought of as nouns. the problem to be solved. which is called the entity's primary key. connected by lines to each of the entities in the relationship.

Ports. • . One useful way to classify these diagrams involves three stages of a typical software development project: requirements. OOD on how the system does it Object diagrams show instances instead of classes. and are often used to provide examples. and the links between the instances. analysis. and Connectors” in Chapter 1). search Example of a Object diagram. An object diagram in the Unified Modeling Language (UML). Object diagram From Wikipedia. Object diagrams are more concrete than class diagrams. Only those aspects of a model that are of current interest need be shown on an object diagram. Hide image Class Diagrams A class diagram focuses on a set of classes (see Chapter 1) and the structural relationships among them (see Chapter 2). and design. especially recursive relationships. These stages are discussed in the following sections. the free encyclopedia Jump to: navigation. They are useful for explaining small pieces with complicated relationships. The UML allows you to draw class diagrams that have varying levels of detail. or act as test cases for the class diagrams.Re: Difference: Object Oriented Analysis (OOA) and Object Oriented Design (OOD)? Answ er #2 OOA focuses on what the system does. is a diagram that shows a complete or partial view of the structure of a modeled system at a specific time. An Object diagram focuses on some particular set of object instances and attributes. A correlated set of object diagrams provides insight into how an arbitrary view of a system is expected to evolve over time. This small class diagram shows that a university Department can contain lots of other Departments. It may also show interfaces (see the section “Interfaces.

when n = 3. The role names are not shown here. then f(n) = 0 + 1 = 1. the same three objects are involved. if any. Object oriented technology is based on a few simple concepts that. an abstract or concrete class) and instance name. and may have an instance name. Other UML entities. and f(n-2) = 1. when combined. and f(n-1) = 1. and f(n-2) = 5. and has val = 1. The topmost instance. An object instance may be called an instance specification or just an instance. and f(n-1) = 8. Unfortunately. and f(n-1) = 1. and may include a value for that entity. has IndependentVariable as its classifier. then f(n) = 5 + 8 = 13. [edit] Usage If you are using a UML modeling tool. the basic concepts of the technology often get lost in the excitement of advanced features and . a role. A link between instances is generally referred to as a link. In the first UML object diagram on the right. Their slots have different values. are included below the names. a ':' separator. After several more iterations. consider one possible way of modeling production of the Fibonacci sequence. is of class IndependentVariable. This can show an object's classifier (e. and plays the N role. has FibonacciFunction as its classifier. The instance and role names are not shown here. but these are not shown here. plays the NMinus2 role within the FibonacciSystem. then f(n) = 1 + 1 = 2. Each slot corresponds to a single attribute or feature. The diagram also includes three named links. such as an aggregation or composition symbol (a diamond) may also appear on an object diagram. and optionally one or more classifier names separated by commas. The second object is named v2. a still later snapshot. as well as attributes and other structural features using slots. and slots. an anonymous instance specification. when n=2. plays the NMinus1 role. and has a slot for the val attribute with a value of 0. but the slots for the val attribute have different values. at a slightly later point in time. and represents an instance of an association. The contents of slots. in a separate attribute compartment. the instance in the leftmost instance specification is named v1. The name on an instance specification optionally shows an instance name. produce significant improvements in software construction. The DependentVariable object is named v3. when n = 7. such as on a class diagram. A link is shown as a solid line.Object diagram topics Instance specifications Each object and link on an object diagram is represented by an InstanceSpecification. Links are instances of an association. and f(n-2) = 0. After the first iteration. you will typically draw object diagrams using some other diagram type. the IndependentVariable and DependentVariable objects are the same. shown as lines. As an example.g. In the second diagram. Object diagram example Initially. In the last object diagram.

That place is called a class. storage dimensions. Each subclass inherits all the properties of its superclass and adds its own properties in it. Stock number. In practice.for example a thousand product objects. this would be ridiculously inefficient. A class can be defined as a generalized form and then it specialized in a subclass. Classification: In principle. The basic characteristics of the OOM are explained ahead. customers and sales orders. But the methods for dealing with these data might well be the same. reorder quantity. Polymorphism: Polymorphism is a Greek word meaning ¡§many forms¡¨.advantageous features. we could send the message "move" to many different kinds of objects. each of which could report its current price. All object-oriented languages provide a simple way of capturing these commonalties in a single place. it raises an awkward problem. Do we have to copy these methods and duplicate them in every object? No. It is used to express the fact that the same message can be sent to many different objects and interpreted in different ways by each object. a car and a bicycle are subclasses of a class road vehicle. but they might do so in very different ways. The basic idea is to define software objects that can interact with each other just as their real world counterparts do. For example. An object is a software package that contains the related data and the procedures. They would all respond to the same message. modeling the way a system works and providing a natural foundation for building systems to manage that business. For example. and any other values would differ from one product to the next. The class acts as a kind of template for objects of similar nature. . as they both inherits all the qualities of a road vehicle and add their own properties to it. price. Characteristics of Object Oriented Technology: * Identity * Classification * Polymorphism * Inheritance Identity: The term Object Oriented means that we organize the software as a collection of discrete objects. Inheritance: Inheritance is the sharing of attributes and operations among classes on a hierarchical relationship. they are most frequently used to represent real-world objects such as products. The move operation will behave differently for a window and differently for a chess piece. Although objects can be used for any purpose. Suppose we have many objects of the same general type. Any data these objects contained could easily be unique for each object. stock on hand. packaging data and procedures together makes perfect sense.

However. Another advantage of dynamic binding is reuse. C++ resolves the dynamic type of s and ensures that the appropriate version of Draw() is invoked. rather. Shape *p2 = new Square.. //overriding Shape::Draw } Draw() is a dummy function in Shape. the static type of both p1 and p2 is "Shape *". Notice how powerful dynamic binding is: You can derive additional classes from Shape that override Draw() even after func() is compiled. However. func(p2). Dynamic binding refers to the mechanism that resolves a virtual function call at runtime. However. Imagine a class hierarchy in which a class called Shape serves as a base class for other classes (Triangle and Square): class Shape { public: void virtual Draw() {} //dummy implementation //. For example.Dynamic Binding Last updated Mar 1. The beauty in polymorphism is that a pointer or a reference to Shape may actually point to an object of class Square or Triangle: void func(const Shape* s) { s->Draw() } int main() { Shape *p1= new Triangle. //overriding Shape::Draw } class Triangle { public: void Draw(). This mechanism is activated when you call a virtual member function through a reference or a pointer to a polymorphic object. dynamic binding isn't confined to the resolution of member function calls at runtime. } C++ distinguishes between a static type and a dynamic type of an object. Likewise. it applies to the binding of a dynamic type to a pointer or a reference that may differ from its static type. The static type is determined at compile time. Earlier. this penalty is negligible in most cases. . When func() invokes Draw(). C++ will still resolve the call according to the dynamic type of s. Such a pointer or reference is said to be polymorphic. As the example shows. func(p1). the dynamic types of these pointers are determined by the type of object to which they point: "Triangle *" and "Square *". Dynamic binding exacts a toll. I explained how dynamic binding and polymorphism are related. Resolving the dynamic type of an object takes place at runtime and therefore incurs performance overhead. the object bound to such a pointer is a polymorphic object. existing code will still function correctly once you've added new classes. You only have to compile the new code and relink the program. When func() calls the member function Draw(). If you decide to introduce additional classes at a later stage. you only have to override Draw() instead of writing entire classes from scratch. respectively. I didn't explain how this relationship is implemented. class Square { public: void Draw(). 2004. It's declared virtual in the base class to enable derived classes to override it and provide individual implementations. }. Furthermore. It's the type specified in the declaration. though.

Ambiguities arise in multiple inheritance. a Worker. A person's age doesn't change if you consider them a Person. Musician. the free encyclopedia Jump to: navigation. however. such as allowing a class named StudentMusician to inherit from a class named Person. For instance. This is referred to as the Diamond problem. Musician. Worker.< BackPage 87 of 438Next > Multiple inheritance From Wikipedia. Tcl (via Incremental Tcl)[1]. or a Musician. it would make sense to join the "Age" features of Person together for StudentMusician. where a class may inherit from at most one superclass. make sense to separate the feature "Name" in Person and Musician if they use a different stage name than their given name. Worker If a compiler is looking at the class StudentMusician it needs to know whether it should join identical features together. Contents [hide] • • • • • • 1 Overview 2 Criticisms 3 See also 4 References 5 Further reading 6 External links [edit] Overview Multiple inheritance allows a class to take on functionality from multiple other classes. Languages that support multiple inheritance include: Eiffel. a class named Musician. Worker StudentMusician : Person. if for instance the class Musician inherited from Person and Worker and the class Worker inherited from Person. OCaml. and a class named Worker. Common Lisp (via CLOS). as in the example above. search Multiple inheritance refers to a feature of some object-oriented programming languages in which a class can inherit behaviors and features from more than one superclass. The options of joining and separating are both valid in their own context and only the programmer knows which option is correct for the class they are designing. C++. Python. Perl. There would then be the following rules: Worker : Person Musician : Person. . This contrasts with single inheritance. Dylan. Languages have different ways of dealing with these problems of repeated inheritance. Perl 6. This can be abbreviated StudentMusician : Person. It would. and Object REXX (via the use of mixin classes). or whether they should be separate features. Curl.

The Common Lisp Object System allows full programmer control of method combination. all but Smalltalk allow classes to implement multiple interfaces. and the secondary constructor will be invoked for all other subclasses. method dispatch. and other internal mechanisms without affecting the stability of the system. However. C++ does not support explicit repeated inheritance since there would be no way to qualify which superclass to use (see criticisms). "Worker::Person" and "Musician::Person" will reference the same object). class instantiation. Shared classes must define a secondary constructor for each regular constructor in the class. B. and this avoids any ambiguity. Curl allows only classes that are explicitly marked as shared to be inherited repeatedly. Tcl allows multiple parent classes. C++ requires that the programmer state which parent class the feature to use should come from i. The compiler uses the first method it finds by depth-first searching of the superclass list or using the C3 linearization of the class hierarchy. Eiffel will automatically join features together if they have the same name and implementation. Objective-C. Ocaml chooses the last matching definition of a class inheritance list to resolve which method implementation to use under ambiguities.[2] • • • • • • • Smalltalk. Eiffel also allows explicit repeated inheritance such as A: B.e. and PHP do not allow multiple inheritance. the Metaobject Protocol gives the programmer a means to modify the inheritance. The regular constructor is called the first time the state for the shared class is initialized through a subclass constructor. Object Pascal / Delphi. but unlike Perl includes it in the syntax of the language. Python has the same structure.their serial affects the name resolution for class members. the order of inheritance affects the class semantics (see criticisms). "Worker::Person. Perl uses the list of classes to inherit from as an ordered list. and if this is not enough. The class writer has the option to rename the inherited features to separate them. Multiple inheritance example #include <iostream> . allowing the declaration of method aliases that provide both renaming and access to methods that would be masked out by the default conflict resolution mechanism. Various extensions provide alternative class composition schemes.• Eiffel allows the programmer to explicitly join or separate features that are being inherited from superclasses. Logtalk supports both interface and implementation multi-inheritance. C++ also allows a single instance of the multiple class to be created via the virtual inheritance mechanism (i. In Perl and Python. Java. To override the default behavior one simply qualifies a method call with the desired class definition.Age".e. C#. Nemerle.

} char getData() const { return letter. using std::cout. .using std::ostream. using std::endl. double double1 ) : Base1( integer ). }. } protected: int value. class Derived : public Base1. } protected: char letter. char character. Base2( character ). real( double1 ) { } double getReal() const { return real. public Base2 { public: Derived( int integer. class Base2 { public: Base2( char characterData ) { letter = characterData. }. } void display() { cout << " Integer: " << value << "\n Character: " << letter << "\nReal number: " << real. class Base1 { public: Base1( int parameterValue ) { value = parameterValue. } int getData() const { return value.

Base2 base2( 'Z' ).19. cout << base2Ptr->getData() << endl.2.getData(). cout << derived. } 10Z Integer: 7 Character: A Real number: 3.Base1::getData() << derived.getReal() << "\n\n". multiple inheritance with employees and degrees .display(). *base2Ptr = 0.19. 3. An example of multiple base classes.multiple base classes 9. Derived derived( 7. }. return 0.getData() << base2.Base2::getData() << derived. base1Ptr = &derived. *base1Ptr = 0. derived. 'A'.} private: double real.5 ).19.57A3. int main() { Base1 base1( 10 ).1. cout << base1Ptr->getData() << '\n'. cout << base1. base2Ptr = &derived.5 7 A 9. 9.

19.19.19.9. } friend std::istream& operator>>(std::istream& is. is fully manageable by the programmer. Heap or dynamic memory.19. Stack or static memory is efficient and memory management is done automatically by the compiler. return is.7. Customer& rhs) { is >> rhs. although slower. 9. #include <iostream> #include <string> #include <vector> using namespace std.4.m_name. 9. multiple inheritance with English Distances Multiple Inheritance to have the features from both parent Resolving Ambiguity in Case of Multiple Inheritance Involving Common Base Classes Multiple Inheritance in both private and public way In cases of multiple inheritance: Constructors are called in order of derivation. } void setName(std::string const& name) { m_name = name. In restrictive programs objects should be stored in stack memory. It is the area of choice for storing data in complex applications where program flow is dictated by the user. 9. In user-driven programs objects should be stored in heap memory.3. 9.8. destructors in reverse order Multiple inheritance example How to Create and Destroy Objects C++ offers software developers two philosophies for creating and destroying objects-static and dynamic. } friend std::ostream& operator<<(std::ostream& os. Customer const& rhs) { os << rhs. } private: std::string m_name. class Customer { public: Customer() : m_name("") {} std::string& getName() { return m_name.6.19. . return os. 9.19.m_name.5.

b. m_vCustomers. } } return 0. typedef std::vector<Customer> vCustomers. if(numCustomers > 0) { Bank b. class Bank { public: Bank() {} Bank(const size_t numCustomers) { for(size_t i = 0. i < numCustomers. cin >> c. int main() { size_t numCustomers = 0.push_back(c). it++) { std::cout << (*it) << endl. }.end().push_back(customer).addCustomer(c). cout << "Enter a name for Customer: ". i++) { Customer c. cout << "Enter the number of customers for a new Bank object: ". } void showCustomers() { vCustomers::iterator it. for(size_t i = 0.}. it != m_vCustomers. } } private: vCustomers m_vCustomers. for(it = m_vCustomers.showCustomers(). cin >> numCustomers.begin(). i++) { Customer c. i < numCustomers. } } void addCustomer(Customer const& customer) { m_vCustomers. } b. .

Our class declaration would now look like this: class Player { int health. One problem with this constructor is that all of the players will be initialized to have strength=10. For our video game. Constructors are called every time you create an object. int agility.3: Constructors and Destructors In addition to all of the member functions you'll create for your objects. agility.2. agility=10. The same is true of objects. } class int int int Player { health.no return type void move(). . and health=10. }. when we first declared a variable? Before we initialized the variable. and destructors are called every time you destroy an object. int strength. strength. so you can't just set it to 0. void getTreasure(). They are called constructors and destructors. we'll probably want to initialize our Players' attributes so that they don't contain garbage values. there are two special kinds of functions that you should create for every object. agility = 10. We might decide to write the constructor like this: We would also have to change the class declaration so that it looks like this: Player::Player() { strength = 10. void attackMonster(). The constructor is a function whose name is the same as the object. We might want to create players with different values for strength and agility to make our game more interesting.Section 7. health = 10. is called when you instantiate an object. // constructor . we can add a second constructor. Player(). So. with no return type (not even void). you can't just assign it a value. Remember in Chapter 3. the constructor. A player is not a number. because that doesn't make sense. Constructors The constructor's job is to set up the object so that it can be used. The difference is that with an object. You can't say: Player greenHat = 0. it stored a garbage value. The way object initialization happens in C++ is that a special function. We needed to initialize the variable to 0 or to some other useful value before using it. which has parameters for strength and agility.

when we want to instantiate the Player object four times. // // // // default constructor alternate constructor alternate constructor alternate constructor Destructors Destructors are less complicated than constructors. Need for Friend Function: As discussed in the earlier sections on access specifiers. // constructor . agility = 0. 12). 10). The name of the destructor is the name of the class. void getTreasure(). Player(int s. Right now. A programmer may have a situation where he or she would need to access private data from non-member functions and external classes. but you'll see why they're important in Section 8. A function that is not a member or an external class will not be able to access the private data. 7). } Since a destructor is called after an object is used for the last time. agility = a.no return type // alternate constructor takes Now. blueHat(14. two parameters void move(). } Player Player Player Player redHat. you're probably wondering why they exist at all. Here's an example of a destructor: Player::~Player() { strength = 0. You don't call them explicitly (they are called automatically for you). int a). then it is not accessible from outside the class. }. when a data is declared as private inside a class. For handling such cases. and there's only one destructor for each object. health = 0. which looks like this: Player(). .and we would add a function definition for the alternate constructor.3. preceeded by a tilde (~). we can do the following: Player::Player(int s. greenHat(6. void attackMonster(). yellowHat(10. int a) { strength = s. they aren't very useful. health = 10. the concept of Friend functions is a useful tool.

. except the function declaration of these functions is preceded with the keyword friend. . by making them friends. seen in example below. It is possible to declare the friend function as either private or public. public: void test() { a=100. even though it is not a member function. It is possible to declare a function as friend in any number of classes. When a class is declared as a friend. . A friend function. Some important points to note while using friend functions in C++: • • • • • • The keyword friend is placed only in the function declaration of the friend function and not in the function definition. would have the rights to access the private members of the class. a friend function is an ordinary function or a member of another class. The friend function has its argument as objects. the friend class has access to the private data of the class that made this a friend.b. . How to define and use Friend Function in C++: The friend function is written as any other normal function. The function can be invoked without the use of an object. A class can allow non-member functions and other classes to access its own private data. Thus.What is a Friend Function? A friend function is used for accessing the non-public members of a class. Example to understand the friend function: #include class exforsys { private: int a. . . The friend function must have the class to which it is declared as friend passed to it in argument.

} friend int compute(exforsys e1) //Friend Function Declaration with keyword friend and with the object of class exforsys to which it is friend passed to it }. int compute(exforsys e1) { //Friend Function Definition which has access to private data return int(e1.test(). . I have got some difficulties in defining a class. } The output of the above program is The result is:295 The function compute() is a non-member function of the class exforsys. it is created as a friend function for the class exforsys. e.a+e2.b)-5. } main() { exforsys e. As a first step. In order to make this function have access to the private data a and b of class exforsys . //Calling of Friend Function with object as argument. the function compute() is declared as friend in the class exforsys as: friend int compute (exforsys e1) need help to define a class in C++ hi I am learning to program in C++.b=200. public ans private type is confusing. cout<<"The result is:"<<COMPUTE(E).

and the number of integer. } c.sort(). } mean=sum/a. I don't think it is working because I don't think I need to read the file "list" if someone can void statistics::count (void) { ifstream list("list.push_back(n). } .txt") container c. int n.anyway the class I want to define should collect information about integers. the sum. at any time she returns the average of the integers. the median (value on the middle of the list. I have thought about define like this: CPP / C++ / C Code: class statistics { private: double mean(void) vector<int> mode(void) double median(void) int sum(void) int count(void) public: void add(int t) }. while (list >> n) { c. a=0. she accepts integers through a method add(). cout << a << endl. a=a++. cout << "the mean is " << mean << endl.

ints x and y in the Point class).push_back(n).void statistics::sum (void) { ifstream list("list. cout << "the mean is " << mean << endl. int n.begin(). sum=0. //=== Point.end(). mean=sum/a. int n. so it is defined with two explicit operands.end().begin(). cout << "the sum is " << sum << endl. .txt") container c. a=0. } void statistics::mean (void) { ifstream list("list. . for (container::iterator i = c. while (list >> n) { c. while (list >> n) c. It is not a member function.txt") container c. Note that operator<< for your type can be defined in terms of << on other types. } for (container::iterator i = c. a=a++. i != c.cpp file =========================== . The operator<< function must return the value of the left operand (the ostream) so that multiple << operators may be used in the same statement. } I don't think it is working because I don't think I need to read the file "list" if someone can give me hints about that. that give me hints about that. . that would Definition The definition of the operator<< function can be in any file. i++) sum = addsum(*i).push_back(n). specifically the types of the data members of your class (eg. i != c. mean=0. i++) sum = addsum(*i).

y <<")". cout << p.1. In order to be able to write the above code we must have the "+" operator overloaded to make the proper addition between the real members and the imaginary ones and also the assignment operator. That is. // for multiple << operators. In this way a programmer can provide his or her own operator to a class by overloading the built-in operator to perform some specific computation when the operator is used with objects of that class. Overloading << and >> Perhaps the most common use of friend functions is overloading << for I/O. but to operators too. it will make the code more clear than using a function to do the task. and imaginary part Complex c = a+b. A short example will make things clear: Complex a(1. // not legal without << friend function Operator Overloading by Andrei Milea In C++ the overloading principle applies not only to functions. when the concept represented by the class is not related to the operator (like using + and .to add and remove elements from a data structure). However. const Point& p) { output << "(" << return output. creating confusion. Using operator overloading is a design decision.ostream& operator<<(ostream& output. // example usage Point p. " << p. One question may arise here: is this really useful in real world implementations? Some programmers consider that overloading is not useful most of the time. to read.x << ".1. . . Comblex b(2.3). This piece of code is not as suggestive as the first one and the readability becomes poor. but sometimes misleading. In this cases operator overloading is a bad idea. and code written by a programmer using operator overloading can be easy. The . so when we deal with concepts where some operator seems fit and its use intuitive. We can use operator overloading easily without knowing all the implementation's complexities. . Even if overloading adds complexity to the language it can provide a lot of syntactic sugar. This example overloads << (ie. //this class is used to represent complex numbers //notice the construction taking 2 parameters for the real //for this to work the addition operator must be overloaded The addition without having overloaded operator + could look like this: a.3).Add(b). the meaning of operators can be extended from built-in types to user-defined types. Complex c(a). This and the fact that overloading makes the language more complicated is the main reason why operator overloading is banned in Java. defines a operator<< function) so that Point objects can use cout and <<. } p. there are many cases when programmers abuse this technique.2.

Add(num2). for example the multiplication takes place before addition. operator& and operator.GetRealPart(). operator(). return temp. The operator=.overloading syntax is quite simple. Complex operator=(Complex).double im) :real(re).imag(im) {}.Complex &num2) { Complex temp(num1). Another intuitive meaning of the "+" operator from the STL string class which is overloaded to do concatenation: string prefix("de"). the implicit or user-defined conversion can allow the operator to act even if the first operand is not exactly of the same type: Complex c = 2+b. a binary operator takes two operands. but their meanings can be changed by overloading or erased by making them private. a unary only one. (sequencing) have already defined meanings by default for all objects. when it's a global function. Almost all operators can be overloaded in C++: + - * / % ^ & | . that is. so their use is restricted just as member functions(non-static). Notice that we had to call the accessor function in order to get the real and imaginary parts from the parameter since they are private. Using "+" to concatenate is also allowed in Java. We could have defined the addition operator globally and called a member to do the actual work: Complex operator+(Complex &num1. The same restriction acts for the precedence too. similar to function overloading. and it's not a user defined behavior. } Complex Complex::operator+(Complex num) { real = real + num.GetImagPart(). the keyword operator followed by the operator we want to overload as you can see in the next code sample: class Complex { public: Complex(double re. } The motivation for doing so can be understood by examining the difference between the two choices: when the operator is a member the first object in the expression must be of that particular type. imag = imag + num. double imag. return *this. The number of operands can't be overridden. //if the integer 2 this expression is valid can be converted by the Complex class. operator[] and operator->. string word("composed"). There are some operators that need the first operand to be left value: operator=. Complex operator+(Complex). In order to bypass this difficulty we could have made the operator + a friend (a friend function is a function which is permitted to access the private members of a class) in the complex class: friend Complex operator+(Complex). } The assignment operator can be overloaded similarly. but note that this is not extensible to other classes. //note the use of a copy constructor here temp. string composed = prefix+word. private: double real. they can't be overloaded globally.

... . The concept of restricted access led programmers to write specialized functions or methods for performing the operations on hidden members of the class... << /= [ ] = >> %= ( ) < == ^= -> > != & = ->* <= && |= new >= || *= delete exceptions are the operators for scope resolution (::). Hiding the implementation details and providing restrictive access leads to the concept of abstract data type. ..... Data encapsulation led to the important concept of data hiding. Encapsulation clearly represents the ability to bundle related data and functionality within a single. Using the method of encapsulation..~ ++ += <<= ! --= >>= . Neither too much access nor too much control must be placed on the operations in order to make the class user friendly. member selection (.. and member selection through a pointer to a function(.).*).... Overloading assumes you specify a behavior for an operator that acts on a user defined type and it can't be used just with general pointers. //Other data members }. The standard behavior of operators for built-in (primitive) types cannot be changed by overlo C++ Encapsulation Introduction Encapsulation is the process of combining data and functions into a single unit called class. Encapsulation leads to the concept of data hiding...... int example(char *se) int endfunc(). float sq.... //Other member functions private: int x.... Attention must be paid to ensure that the class is designed properly. Data hiding is the implementation details of a class that are hidden from the user. . .. the programmer cannot directly access the data.. but the concept of encapsulation must not be restricted to information hiding.... For instance: class Exforsys { public: int sample().. Data is only accessible through the functions present inside the class... autonomous entity called a class. .

The programmer is then able to utilize the concept of friend functions. the calling objects will not know the implementation details. Encapsulation alone is a powerful feature that leads to information hiding. protected or private. A class placed after the keyword public is accessible to all the users of the class. making maintenance much easier on the class level. Elements placed after the keyword protected are accessible only to the methods of the class or classes derived from that class. but in some cases the programmer might require an unrelated function to operate on an object of two different classes. float sq and other data members and member functions sample(). the data members integer x. This exemplifies the concept of Encapsulation. Features and Advantages of the concept of Encapsulation: * Makes Maintenance of Application Easier: Complex and critical applications are difficult to maintain. In between the public and the private access specifiers. There are advantages of using this encapsulated approach in C++. This enhances the security of the application. The concept of encapsulation shows that a non-member function cannot access an object's private or protected data. the object-oriented programming language C++ created the concept of encapsulation which bundles data and related functions together as a unit called class. It is clear from the above example that the encapsulated objects act as a black box for other parts of the program through interaction. To resolve this maintenance difficulty. * Improves the Understandability of the Application * Enhanced Security: .In the above example.endfunc() and other member functions are bundled and put inside a single autonomous entity called class Exforsys. The elements placed after the keyword private are accessible only to the methods of the class. One advantage is that it reduces human errors. This adds security. The key strength behind Data Encapsulation in C++ is that the keywords or the access specifiers can be placed in the class declaration as public. abstract data type and friend functions. This special feature is available in object-oriented language C++ but not available in procedural language C. The cost associated with maintaining the application is higher than that of developing the application properly. The data and functions bundled inside the class take total control of maintenance and thus human errors are reduced. Thus. Although encapsulated objects provide functionality.example(char* se). there exists the protected access specifier.

The following section attempts to provide some perspective on the methods of parallel computing and indicate where the Beowulf machine falls on this continuum. Extra CPUs definitely help in these situations. The access specifier acts as the key strength behind the concept of security and provides access to members of class as needed by users. There are basically two hardware issues involved with design of a Beowulf system: the type of nodes or computers you are going to use. a rendering program. Unlike the "sequential world" where processor speed is considered the single most important factor. and way you connect the computer nodes. This prevents unauthorized access.and it is. Indeed. your expectations will be more realistic and success will be more likely. Why more than one CPU? Answering this question is important. 4. In general. or a project scheduler? Maybe extra CPUs would help. there by giving an additional security to existing application. This section provides background on parallel computing concepts. a database. It is a brief description of the issues that may be important to a Beowulf designer and user. What about a web server.There are numerous reasons for the enhancement of security using the concept of Encapsulation in C++. System Design Before you purchase any hardware. Using 8 CPUs to run your word processor sounds a little like "over-kill" -. multiple CPUs are being used to solve more and more problems. Indeed. While the number of choices is not large.2 The methods of parallel computing Parallel computing can take many forms. it may be a good idea to consider the design of your system. it is not all that difficult to understand the issues involved with parallel computing. Because the science (or art) of "parallel computing" has many different interpretations. A more detailed discussion of hardware and communication software is provided later in this document. once the issues are understood. As you design and build your Beowulf.1 A brief background on parallel computing. 4. 4. a fluid dynamics code. many of these issues described below will become important in your decision process. but it is advised that you read section Suitability before you make you final hardware decisions. If you do not like to read background material. What about a complex simulation. From a user's perspective. a Beowulf Supercomputer requires that we consider many factors carefully because they are now under our control. or a data mining application. Due to its component nature. the communication library or API. . there are some important design decisions that must be made when constructing a Beowulf systems. There is one software issue that may effect your hardware decisions. processor speed in the "parallel world" is just one of several factors that will determine overall system performance and efficiency. it is important to consider the advantages and disadvantages of each methodology. It is NOT an exhaustive or complete description of parallel computing science and technology. the task of adding new functions becomes easier without breaking existing code or applications. an introduction is provided below. you may skip this section. If an application needs to be extended or customized in later stages of development.

I will just wait for the 986 turbo-hyper chip. Computer Example: MS DOS Multi-tasking Operating System: One cash register open. 2. Because parallel computing is implemented in a variety of ways. 4. these speeds are not increasing as fast as the CPU speeds. solving your problem in parallel will require some very important decisions to be made. . The Parallel Computing Store Consider a big store with 8 cash registers grouped together in the front of the store." There are several reasons: 1. Due to the use of multi-tasking Operating Systems.waiting in long lines at a store. 3. Keep in mind most applications require "out of cache memory access" and hard disk access. If you need speed . Assume each cash register/cashier is a CPU and each customer is a computer program. These decisions may dramatically effect portability.off-the-shelf" CPUs. Doing things in parallel is one way to get around some of these limitations. you will get through the line faster. Before we get technical. This is called SMP . This is a natural "parallelism" that is easily exploited by more than one low cost CPU. but what about RAM speeds or hard disk speeds? Unfortunately. Depending on the application. NT using a single CPU Multitasking Operating Systems with Multiple CPUs: Now we open several cash registers in the store. parallel computing can speed things up by any where from 2 to 500 times faster (in some cases even faster). Even supercomputers that at one time used very fast custom processors are now built from multiple "commodity. you will still never get through the line any faster than just you and a single cash register. parallel is worth considering. The following analogies can be used to illustrate parallel computing concepts. performance. and cost of your application. Each order can be processed by a separate cash register and the line can move much faster.The next question usually is: "Why do I need two or four CPUs. Predictions indicate that processor speeds will not continue to double every 18 months after the year 2005. Computer Example: UNIX. Processor speeds have been doubling every 18 months. Although there are extra cash registers open. Such performance is not available using a single processor.Symmetric Multi-processing. move to the next person and process some of their order.either due to a compute bound problem and/or an I/O bound problem. Everyone "seems" to be moving through the line together. but if no one else is in the line. but now we process only a part of each order at a time. The size of the computer program (amount of work) is the size of each customer's order. let's look take a look at a real "parallel computing problem" using an example with which we are familiar . There are some very serious obstacles to overcome in order to maintain this trend. it is possible to do several things at once. Single-tasking Operating System One cash register open (is in use) and must process each customer one at a time.

as to how many cash registers the store can effectively locate in any one place.parallel applications communicate using shared memory. Hardware Architectures There are basically two ways parallel computer hardware is put together: 1. they can exchange information quickly by looking and talking to all the other "local" cash registers.Computer Example: UNIX and NT with multiple CPUs Threads on a Multitasking Operating Systems extra CPUs If you "break-up" the items in your order. Local memory machines that communicate by messages (Beowulf Clusters) 2. A 4 way SMP box is a shared memory machine and can be used for parallel computing . This distance adds extra overhead (time) to communication between cashiers. Sending Messages on Multitasking Operating Systems with extra CPUs: In order to improve performance.each cash register (or island) must communicate by phone. Just as in . Unlike a single CPU (or cash register) communication is an issue. the store adds 8 cash registers at the back of the store. Computer Example: UNIX or NT with extra CPU on the same motherboard running multithreaded programs. however. it does not matter too much where they are. are a good representation of constraints placed on parallel systems. the cashiers must call on the phone to send their sub-totals to the front of the store. we must assume you have a large amount of goods. There is a limit. you might be able to move through the line faster by using several cash registers at one time. then as before your speed can be improved by using all cash registers at the same time. the extra overhead must be considered. it is not a problem. If you have a really big order. While this description is by no means exhaustive. In some cases. They can even snoop around the other cash registers to find information they need to work faster. therefore. In theory. where "n" is the number of cash registers. Since all the cashiers working the cash registers can talk to each other by phone. you should be able to move through the line "n" times faster than before*.3 Architectures for parallel computing The common methods and architectures of parallel computing are presented below. 4. it is enough to understand the basic issues involved with Beowulf design. When the cashiers need to get sub. Amdals law will also limit the application speed-up to the slowest sequential portion of the program. although not exact. because the time you invest "breaking up your order" must be regained by using multiple cash registers. Computer Example: One or several copies of UNIX or NT with extra CPUs on the same or different motherboard communicating through messages. The above scenarios. a local memory machine. Because the new cash registers are far away from the front cash registers. one that requires all the cash registers. but if communication is minimized. the store may have single cash registers (or islands of cash registers) located all over the store . First.totals. Shared memory machines that communicate through memory (SMP machines) A typical Beowulf is a collection of single CPU machines connected using fast Ethernet and is.

the computer store analogy, local memory machines (individual cash registers) can be scaled up to large numbers of CPUs, while the number of CPUs shared memory machines (the number of cash registers you can place in one spot) can have is limited due to memory contention. It is possible, however, to connect many shared memory machines to create a "hybrid" shared memory machine. These hybrid machines "look" like a single large SMP machine to the user and are often called NUMA (non uniform memory access) machines because the global memory seen by the programmer and shared by all the CPUs can have different latencies. At some level, however, a NUMA machine must "pass messages" between local shared memory pools. It is also possible to connect SMP machines as local memory compute nodes. Typical CLASS I motherboards have either 2 or 4 CPUs and are often used as a means to reduce the overall system cost. The Linux internal scheduler determines how these CPUs get shared. The user cannot (at this point) assign a specific task to a specific SMP processor. The user can however, start two independent processes or a threaded processes and expect to see a performance increase over a single CPU system.

Software API Architectures
There basically two ways to "express" concurrency in a program:
1. Using Messages sent between processors 2. Using operating system Threads

Other methods do exist, but these are the two most widely used. It is important to remember that the expression of concurrency is not necessary controlled by the underlying hardware. Both Messages and Threads can be implemented on SMP, NUMA-SMP, and clusters - although as explained below efficiently and portability are important issues.

Messages
Historically, messages passing technology reflected the design of early local memory parallel computers. Messages require copying data while Threads use data in place. The latency and speed at which messages can be copied are the limiting factor with message passing models. A Message is quite simple: some data and a destination processor. Common message passing APIs are PVM or MPI. Message passing can be efficiently implemented using Threads and Messages work well both on SMP machine and between clusters of machines. The advantage to using messages on an SMP machine, as opposed to Threads, is that if you decided to use clusters in the future it is easy to add machines or scale your application.

Threads
Operating system Threads were developed because shared memory SMP (symmetrical multiprocessing) designs allowed very fast shared memory communication and synchronization between concurrent parts of a program. Threads work well on SMP systems because communication is through shared memory. For this reason the user must isolate local data from global data, otherwise programs will not work properly. In contrast to messages, a large amount of copying can be eliminated with threads because the data is shared between processes (threads). Linux supports POSIX threads. The problem with threads is that it is difficult to extend them beyond one SMP machine and because data is shared between CPUs, cache coherence issues can contribute to overhead. Extending threads beyond the SMP boundary efficiently requires NUMA technology which is expensive and not natively supported by Linux. Implementing threads on top of messages has been done (

(http://syntron.com/ptools/ptools_pg.htm)), but Threads are often inefficient when implemented using messages. The following can be stated about performance: SMP machine cluster of machines performance performance ----------------------------messages good best threads best poor* scalability ----------best poor*

* requires expensive NUMA technology.

Application Architecture
In order to run an application in parallel on multiple CPUs, it must be explicitly broken in to concurrent parts. A standard single CPU application will run no faster than a single CPU application on multiple processors. There are some tools and compilers that can break up programs, but parallelizing codes is not a "plug and play" operation. Depending on the application, parallelizing code can be easy, extremely difficult, or in some cases impossible due to algorithm dependencies. Before the software issues can be addressed the concept of Suitability needs to be introduced.

4.4 Suitability
Most questions about parallel computing have the same answer: "It all depends upon the application." Before we jump into the issues, there is one very important distinction that needs to be made the difference between CONCURRENT and PARALLEL. For the sake of this discussion we will define these two concepts as follows: CONCURRENT parts of a program are those that can be computed independently. PARALLEL parts of a program are those CONCURRENT parts that are executed on separate processing elements at the same time. The distinction is very important, because CONCURRENCY is a property of the program and efficient PARALLELISM is a property of the machine. Ideally, PARALLEL execution should result in faster performance. The limiting factor in parallel performance is the communication speed and latency between compute nodes. (Latency also exists with threaded SMP applications due to cache coherency.) Many of the common parallel benchmarks are highly parallel and communication and latency are not the bottle neck. This type of problem can be called "obviously parallel". Other applications are not so simple and executing CONCURRENT parts of the program in PARALLEL may actually cause the program to run slower, thus offsetting any performance gains in other CONCURRENT parts of the program. In simple terms, the cost of communication time must pay for the savings in computation time, otherwise the PARALLEL execution of the CONCURRENT part is inefficient. The task of the programmer is to determining what CONCURRENT parts of the program SHOULD be executed in PARALLEL and what parts SHOULD NOT. The answer to this will

determine the EFFICIENCY of application. The following graph summarizes the situation for the programmer:

| * | * | * % of | * appli- | * cations | * | * | * | * | * | * | **** | **** | ******************** +----------------------------------communication time/processing time In a perfect parallel computer, the ratio of communication/processing would be equal and anything that is CONCURRENT could be implemented in PARALLEL. Unfortunately, Real parallel computers, including shared memory machines, are subject to the effects described in this graph. When designing a Beowulf, the user may want to keep this graph in mind because parallel efficiency depends upon ratio of communication time and processing time for A SPECIFIC PARALLEL COMPUTER. Applications may be portable between parallel computers, but there is no guarantee they will be efficient on a different platform. IN GENERAL, THERE IS NO SUCH THING AS A PORTABLE AND EFFICIENT PARALLEL PROGRAM There is yet another consequence to the above graph. Since efficiency depends upon the comm./process. ratio, just changing one component of the ratio does not necessary mean a specific application will perform faster. A change in processor speed, while keeping the communication speed that same may have non- intuitive effects on your program. For example, doubling or tripling the CPU speed, while keeping the communication speed the same, may now make some previously efficient PARALLEL portions of your program, more efficient if they were executed SEQUENTIALLY. That is, it may now be faster to run the previously PARALLEL parts as SEQUENTIAL. Furthermore, running inefficient parts in parallel will actually keep your application from reaching its maximum speed. Thus, by adding faster processor, you may actually slowed down your application (you are keeping the new CPU from running at its maximum speed for that application) UPGRADING TO A FASTER CPU MAY ACTUALLY SLOW DOWN YOUR APPLICATION So, in conclusion, to know whether or not you can use a parallel hardware environment, you need to have some insight into the suitability of a particular machine to your application. You need to look at a lot of issues including CPU speeds, compiler, message passing API, network,

It may be that for a given system. the program is not PARALLELIZED. at some point you will need to look at the efficiency issues. this step may require trial and error tests or just a plain old educated guess. Estimate parallel efficiency Without the help of tools. then this step can be some what difficult for existing applications. but in reality only the CONCURRENT parts of the program have been located. >From a practical standpoint. A final note about a common misconception.etc. In either case. Efficient PARALLELIZATION is a property of the machine. a compute bound problem may need a few very fast CPUs and high speed low latency network. does not give the whole story. applications may exhibit two types of concurrency: compute (number crunching) and I/O (database). You may identify a computationally heavy portion of your program. Parallelization decisions will be made in step 2. there are three things you need to do: 1. Please note. Although in many cases compute and I/O concurrency are orthogonal. Estimate parallel efficiently 3. There are tools available that can perform concurrency analysis on existing applications. For all the reasons given above.5 Writing and porting parallel software Once you decide that you need parallel computing and would like to design and build a Beowulf. Determine concurrent parts of your program This step is often considered "parallelizing your program". there are application that require both. the communication cost as do not make parallelizing this code efficient. The requirements of your Beowulf may be quite different depending upon your needs. In this step. just profiling an application. Describing the concurrent parts of your program Let's look at these one at a time. It is often stated that "a program is PARALLELIZED". Go ahead and construct a CLASS I Beowulf and then "fit" your application to it. In general. you need to determine data dependencies. Determine concurrent parts of your program 2. . For example. If no tools are available. try to determine if it is CPU limited (compute bound) or hard disk limited (I/O bound). In general there are two things you can do: 1. Or run existing parallel applications that you know work on your Beowulf (but beware of the portability and efficiently issues mentioned above) 2. If you have a specific application in mind. a few moments considering your application with respect to the previous discussion may be a good idea. Look at the applications you need to run on your Beowulf and make some estimations as to the type of hardware and software you need. 4. There are two reasons FORTRAN is used: historically most number crunching applications were written in FORTRAN and it is easier to analyze. Most of these tools are designed for FORTRAN. but you do not know the communication cost for this portion. while an I/O bound problem may work better with more slower CPUs and fast Ethernet.

scatter/gather functions). efficiently trade-off) For historical reasons.e. (Keep in mind however. libraries.This recommendation often comes as a surprise to most people because.) for parallel computing. If a compute bound loop measured in minutes and the data can be transferred in seconds. The use of pointers in C makes determining data dependencies extremely difficult. While this may be true as C is the closest thing to a universal machine code. the standard assumption is that faster processor are always better.plogic. if you take a 16 minute loop and break it into 32 parts.write existing FORTRAN applications in C with the notion the C will allow faster execution. it is also possible to use standard libraries that have been written for parallel computers. etc. In addition. the one which has slower processors (and a probably correspondingly slower interprocessor communication network) will have better performance for I/O-dominant applications. But remember. most number crunching codes are written in FORTRAN. you find it interesting to download the paper Performance Considerations for I/O-Dominant Applications on Parallel Computers (Postscript format 109K ) (ftp://www. Explicit methods tend to be the most difficult to implement and debug. See Section Software for a description of Software tools. Users typically embed explicit function calls in standard FORTRAN 77 or C/C++ source code. then it might be a good candidate for parallelization. Keep in mind. While this is true if your have an unlimited budget. it has some major drawbacks. Implicit parallel execution The major difference between the two is that explicit parallelism is determined by the user where implicit parallelism is determined by the compiler.DO NOT CONVERT IT TO C! Implicit Methods . The MPI library has added some functions to make some standard parallel methods easier to implement (i. For I/O bound problems. you will need to estimate how efficient it will be in parallel. threads can not move between SMP motherboards).com/pub/papers/exs-pap6. real systems may have cost constraints that should be maximized. Explicit parallel execution 2. Explicit Methods These are basically method where the user must modify source code specifically for a parallel computer. the portability vs. Many programmers now use C or re. The user must either add messages using PVM or MPI or add threads using POSIX threads. Describing the concurrent parts of your program There are several ways to describe concurrent parts of your program: 1. you may try to guess your way through this step. You will reach a point of diminishing returns. FORTRAN has the largest amount of support (tools. While the proof of this rule is beyond the scope of this document. then things are going to get tight. and your data transfers require several seconds per part. there is a little known rule (called the Eadline-Dedkov Law) that is quite helpful: For two given parallel computers with the same cumulative CPU performance index.ps) Once you have determined what type of concurrency you have in your application. For this reasons. In the absence of tools. however. If you have an existing FORTRAN program and think that you might want to parallelize it in the future . Automatic analysis of pointers is extremely difficult.

Object-oriented design From Wikipedia.1 Input (sources) for object-oriented design 2. An object-oriented program is described by the interaction of these objects.2 Object-oriented concepts 2. Object-oriented design is the discipline of defining the objects and their interactions to solve a problem that was identified and documented during object-oriented analysis. and a whole collection of other methods that are under development. Contents [hide] • • 1 Overview 2 Object-oriented design topics ○ ○ ○ ○ ○ • • • 2. is also defined. search "OOD" redirects here. Examples are FORTRAN 90. the free encyclopedia Jump to: navigation. . Officer of the day.Implicit methods are those where the user gives up some (or all) of the parallelization decisions to the compiler. The 'object interface'. or the Ood. but the compiler will then make many decisions about how to execute this concurrency in parallel.4 Output (deliverables) of object-oriented design 2.5 Some design principles and strategies 3 See also 4 References 5 External links [edit] Overview An object contains encapsulated data and procedures grouped together to represent an entity. but there is still no "best way" to describe a concurrent problem for a parallel computer. how the object can be interacted with. Bulk Synchronous Parallel (BSP). Implicit methods require the user to provide some information about the concurrent nature of their application. It is one approach to software design. OOD may also refer to Officer of the Deck.3 Designing concepts 2. These methods provide some level of portability and efficiency. Object-oriented design is the process of planning a system of interacting objects for the purpose of solving a software problem. High Performance FORTRAN (HPF).

it is possible to develop the relational data model and the object-oriented design artefacts in parallel. [edit] Object-oriented design topics [edit] Input (sources) for object-oriented design The input for object-oriented design is provided by the output of object-oriented analysis. which does not include object prototype-based approaches where objects are not typically obtained by instancing classes but by cloning other (prototype) objects. in a certain company. a business object can consist of people. However. vehicles. Realize that an output artifact does not need to be completely developed to serve as input of object-oriented design. their order. Use case actors may be end users or other systems. Use case diagrams are used to identify the actor (users or other systems) and the processes they perform. but it helps to visualize the end-product and therefore helps the designer. The conceptual model is explicitly chosen to be independent of implementation details. it captures concepts in the problem domain. the events that external actors generate. analysis and design may occur in parallel. and possible inter-system events. Both analysis and design can be performed incrementally. and the growth of an artefact can stimulate the refinement of other artefacts. Relational data model (if applicable): A data model is an abstract model that describes how data is represented and used.From a business perspective. It is not mandatory to have this. and the artifacts can be continuously grown instead of completely developed in one shot. such as concurrency or data storage. Some typical input artifacts for object-oriented design are: • Conceptual model: Conceptual model is the result of object-oriented analysis. Object Oriented Design refers to the objects that make up that business. data files and database tables. equipment. • • • • [edit] Object-oriented concepts The five basic concepts of object-oriented design are the implementation level features that are built into the programming language. What follows is a description of the class-based subset of object-oriented design. Use case: Use case is description of sequences of events that. the relational data model should usually be created before the design. artifacts. For example. User interface documentations (if applicable): Document that shows and describes the look and feel of the end product's user interface. lead to a system doing something useful. for a particular scenario of a use case. since the strategy chosen for object-relational mapping is an output of the OO design process. If an object database is not used. etc. taken together. In many circumstances use cases are further elaborated into use case diagrams. These features are often referred to by these common names: . System Sequence Diagram: System Sequence diagram (SSD) is a picture that shows. Each use case provides one or more scenarios that convey how the system should interact with the users called actors to achieve a specific business goal or function. and in practice the results of one activity can feed the other in a short feedback cycle through an iterative process.

in a context[1]. Identify and define remote objects (if applicable). • • • • [edit] Designing concepts • • • • • • • [edit] Output (deliverables) of object-oriented design . without specifying the final application classes or objects that are involved. which is a set of objects that are similar. much time is saved for the developer. An object can be part of a class. Defining objects. creating class diagram from conceptual diagram: Usually map entity to class. Information hiding: The ability to protect some components of the object from external entities. This is realized by language keywords to enable a variable to be declared as private or protected to the owning class. Define application framework (if applicable): Application framework is a term usually used to refer to a set of libraries or classes that are used to implement the standard structure of an application for a specific operating system. The ability to define the functions or methods signatures without implementing them. The ability of an object-variable to contain. what it is and what it can do. but also all of its subobjects. or object (an object is created based on a class). Identify persistent objects/data (if applicable): Identify objects that have to last longer than a single runtime of the application. If a relational database is used. Object-oriented design patterns typically show relationships and interactions between classes or objects. since he/she is saved the task of rewriting large amounts of standard code for each new application that is developed. The so-called subclass has a whole section that is derived (inherited) from the superclass and then it has its own set of functions and data. Polymorphism: The ability to replace an object with its subobjects. not only that object. Sequence Diagrams: Extend the System Sequence Diagram to add specific objects that handle the system events. The main advantage of using a design pattern is that it can be reused in multiple applications. design the object relation mapping. It is defined by its properties. Use design patterns (if applicable): A design pattern is not a finished design. This is called a class. Identifying attributes. Inheritance: The ability for a class to extend or override functionality of another class. It can also be thought of as a template for how to solve a problem that can be used in many different situations and/or applications. Interface: The ability to defer the implementation of a method. By bundling a large amount of reusable code into a framework. Each object serves a separate function.• Object/Class: A tight coupling or association of data structures with the methods or functions that act on the data. it is a description of a solution to a common problem.

which depends on package A. from 1980 onwards. Contents [hide] • • • • 1 Overview 2 History 3 SSADM techniques 4 Stages ○ ○ ○ 4. SSADM was produced for the Central Computer and Telecommunications Agency (now Office of Government Commerce).1 Stage 0 . as parallel vertical lines.Investigation of the current environment 4. different processes or objects that live simultaneously. and. the free encyclopedia Jump to: navigation. Acyclic dependencies principle: The dependency graph of packages or components should have no cycles. in the order in which they occur. Composite reuse principle: Favor polymorphic composition of objects over inheritance.2 Stage 1 . package C depends on package B.Business system options . the messages exchanged between them. then you would have a cycle. search Structured Systems Analysis and Design Method (SSADM) is a systems approach to the analysis and design of information systems. being passed a database connection as an argument to the constructor instead of creating one internally.Feasibility study 4. The messages and classes identified through the development of the sequence diagrams can serve as input to the automatic generation of the global class diagram of the system.[1] [edit] Some design principles and strategies • • • Structured Systems Analysis and Design Method From Wikipedia. Dependency injection: The basic idea is that if an object depends upon having an instance of some other object then the needed object is "injected" into the dependent object. and the relationships between the classes. for example. their attributes. as horizontal arrows.3 Stage 2 . • Class diagram: A class diagram is a type of static structure UML diagram that describes the structure of a system by showing the system's classes. This is also referred to as having a directed acyclic graph. If package A also depended on package C.A sequence diagram shows. a UK government office concerned with the use of technology in government. [2] For example.

adopted by NCC 1988: SSADM Certificate of Proficiency launched.4 Stage 3 .6 Stage 5 .[citation needed] [edit] History • • • • • • • • • • 1980: Central Computer and Telecommunications Agency (CCTA) evaluate analysis and design methods.Requirements specification 4.2 launched [edit] SSADM techniques The three most important techniques that are used in SSADM are: . SSADM promoted as ‘open’ standard 1989: Moves towards Euromethod. Edward Yourdon's Yourdon Structured Method. such as Peter Checkland's Soft Systems Methodology. The names "Structured Systems Analysis and Design Method" and "SSADM" are now Registered Trade Marks of the Office of Government Commerce (OGC). V4. and contrasts with more contemporary Rapid Application Development methods such as DSDM. Michael A.○ ○ ○ ○ • • • 4. 1981: Learmonth & Burchett Management Systems (LBMS) method chosen from shortlist of five. which is an Office of the United Kingdom's Treasury.Logical design 4.Physical design 5 Advantages and disadvantages 6 References 7 External links [edit] Overview SSADM is a waterfall method by which an Information System design can be arrived at. launch of CASE products certification scheme 1990: Version 4 launched 1993: SSADM V4 Standard and Tools Conformance Scheme Launched 1995: SSADM V4+ announced.7 Stage 6 . and Tom DeMarco's Structured Analysis.5 Stage 4 . SSADM is one particular implementation and builds on the work of different schools of structured analysis and development methods. Larry Constantine's Structured Design. SSADM can be thought to represent a pinnacle of the rigorous document-led approach to system design. Jackson's Jackson Structured Programming. 1983: SSADM made mandatory for all new information system developments 1984: Version 2 of SSADM released 1986: Version 3 of SSADM released.Technical system options 4.

data stores (the holding areas for data). Data Flow Modeling This is the process of identifying.is the project technically possible? Financial . Data Flow Modeling examines processes (activities that transform data from one form to another). [edit] Stages The SSADM method involves the application of a sequence of analysis. and data flows (routes by which data can flow). SSADM specifies the sections that the study should contain including any preliminary models that have been constructed and also details of rejected options and the reasons for their rejection. The data are separated into entities (things about which a business needs to record information) and relationships (the associations between the entities).will the new system be compatible with existing practices? Ethical .Investigation of the current environment This is one of the most important stages of SSADM. The developers of SSADM understood that though the tasks and objectives of a new system may be radically different from the old system.Logical Data Modeling This is the process of identifying. the feasibility study is effectively a condensed version of a fullyblown systems analysis and design. Entity Behavior Modeling This is the process of identifying. When a feasibility study is carried out. some business options are drawn up and even some details of the technical implementation. documentation and design tasks concerned with the following.is the impact of the new system socially acceptable? To answer these questions. The product of this stage is a formal feasibility study document. modeling and documenting how data moves around an information system. For very small scale projects this may not be necessary at all as the scope of the project is easily apprehended. there must be some form of investigation into the goals and implications of the project. The requirements and users are analyzed to some extent. [edit] Stage 0 . In larger projects. [edit] Stage 1 . external entities (what sends data into a system or receives data from a system). the feasibility may be done but in an informal sense. . modeling and documenting the events that affect each entity and the sequence in which these events occur. modeling and documenting the data requirements of the system being designed. either because there is not time for a formal study or because the project is a “must-have” and will have to be done one way or the other.Feasibility study In order to determine whether or not a given project is feasible or not. there are four main areas of consideration: • • • • Technical .can the business afford to carry out the project? Organizational .

To do this. The ideas are then collected to form a set of two or three different options which are presented to the user. he or she. The final version is the current logical model which is essentially the same as the current physical but with all reference to implementation removed together with any redundancies such as repetition of process or data. that is. [edit] Stage 2 . the first set of data-flow diagrams (DFDs) are the current physical model.the underlying data will probably change very little. the analyst must decide on the overall design of the new system.Business system options Having investigated the current system. what users do and how they do it the old system provides the core requirements for the new system faults. using the outputs of the previous stage. However. This serves many purposes: • • • • • • • • • • • • • the analyst learns the terminology of the business. In almost all cases there is some form of current system even if it is entirely composed of people and paper. the analyst will discover the information that makes up the users and requirements catalogues. By coming to a full understanding of the data requirements at an early stage. with full details of how the old system is implemented. develops a set of business system options. circulating questionnaires. The analyst may hold a brainstorming session so that as many and various ideas as possible are generated. the remaining analysis and design stages can be built up on a firm foundation. the analyst works through the construction of the models as we have described. errors and areas of inefficiency are highlighted and their reparation added to the requirements the data model can be constructed the users become involved and learn the techniques and models of the analyst the boundaries of the system can be defined Users Catalogue describing all the users of the system and how they interact with it Requirements Catalogues detailing all the requirements of the new system Current Services Description further composed of Current environment logical data structure (ERD) Context diagram (DFD) Levelled set of DFDs for current logical system Full data dictionary including relationship between data stores and entities The products of this stage are: To produce the models. observations and existing documentation. the analyst comes to full understanding of the system as it is at the start of the project. Through a combination of interviewing employees. These are different ways in which the new system could be produced varying from doing nothing to throwing out the old system entirely and building an entirely new one. In the process of preparing the models. The options consider the following: .

By logical. a complement to entity life-histories. ambiguity and inconsistency. Like the Business System Options. The output of this stage is the single selected business option together with all the outputs of stage 1. The product of this stage is a complete Requirements Specification document which is made up of: • • • • • • • • the updated Data Catalogue the updated Requirements Catalogue the Processing Specification which in turn is made up of user role/function matrix function definitions required logical data model entity life-histories effect correspondence diagrams Though some of these items may be unfamiliar to you. To produce the logical specification. entity life-histories (ELHs) and effect correspondence diagrams. This may be one of the ones already defined or may be a synthesis of different aspects of the existing options. these are models of how each event interacts with the system. for example. the requirements are added to and completed. The specification must be free from error. . the option will be documented with a logical data structure and a level 1 dataflow diagram. is it centralized to one office or spread out across several? cost/benefit impact of the new system Where necessary. it is beyond the scope of this unit to go into them in great detail. in this stage a large number of options for the implementation of the new system are generated. we mean that the specification does not say how the system will be implemented but rather describes what the system will do. These are used to produce function definitions of every function which the users will require of the system. This is honed down to two or three to present to the user from which the final option is chosen or synthesised. These are continually matched against the requirements and where necessary.Requirements specification This is probably the most complex stage in SSADM. The users and analyst together choose a single business option. [edit] Stage 4 . Using the requirements developed in stage 1 and working within the framework of the selected business option.• • • • • the degree of automation the boundary between the system and the users the distribution of the system.Technical system options This stage is the first towards a physical implementation of the new system. the analyst must develop a full logical specification of what the new system must do. the analyst builds the required logical models for both the data-flow diagrams (DFDs) and the entity relationship diagrams (ERDs). [edit] Stage 3 .

the outputs of this stage are implementation-independent and concentrate on the requirements for the human computer interface.However. The logical data structure is converted into a physical architecture in terms of database structures. . The exact structure of the functions and how they are implemented is specified. the considerations are quite different being: • • • • • • • the hardware architectures the software to use the cost of the implementation the staffing required the physical limitations such as a space occupied by the system the distribution including any networks which that may require the overall format of the human computer interface All of these aspects must also conform to any constraints imposed by the business such as available money and standardisation of hardware and software. [edit] Stage 5 . The three main areas of activity are the definition of the user dialogues. The product is a complete Physical Design which could tell software engineers how to build the system in specific details of hardware and software and to the appropriate standards. These are the main interfaces with which the users will interact with the system.Logical design Though the previous level specifies details of the implementation. The output of this stage is a chosen technical system option. The physical data structure is optimized where necessary to meet size and performance requirements.Physical design This is the final stage where all the logical specifications of the system are converted to descriptions of the system in terms of real hardware and software. This is a very technical stage and an simple overview is presented here. Both of these use the events. The logical design specifies the main methods of interaction in terms of menu structures and command structures. The other two activities are concerned with analyzing the effects of events in updating the system and the need to make enquiries about the data on the system. function descriptions and effect correspondence diagrams produced in stage 3 to determine precisely how to update and read data in a consistent and secure way. The product of this stage is the logical design which is made up of: • • • • • Menu structures Command structures Requirements catalogue Data catalogue Required logical data structure Logical process model which includes dialogues and model for the update and enquiry processes [edit] Stage 6 .

The main advantages of SSADM are: • • • • • Three different views of the system Mature Separation of logical and physical aspects of the system Well-defined techniques and documentation User involvement The size of SSADM is a big hindrance to using it in all circumstances.[edit] Advantages and disadvantages Using this methodology involves a significant undertaking which may not be suitable to all projects. but there are also a lot of standards for the preparation and presentation of documents. The learning curve is considerable as not only are there several modeling techniques to come to terms with. . There is a large investment in cost and time in training people to use the techniques.

Sign up to vote on this title
UsefulNot useful