You are on page 1of 31

Further Programming Concepts in C++

Table of Contents
Table of Contents...............................................................................................................1 Assumptions......................................................................................................................2 Designing the Solution.......................................................................................................3 Class Diagram................................................................................................................5 UML Concepts (Local Design).......................................................................................6 Association.................................................................................................................6 Composition................................................................................................................6 Generalization.............................................................................................................6 Object Oriented Concepts .............................................................................................7 Objects........................................................................................................................7 Classes.......................................................................................................................8 Inheritance..................................................................................................................9 Polymorphism.............................................................................................................9 Encapsulation...........................................................................................................10 Implementation................................................................................................................11 Validations....................................................................................................................15 Special Features..........................................................................................................20 Screens............................................................................................................................21 Test Plans........................................................................................................................24 1

Further Programming Concepts in C++ Limitations........................................................................................................................28 References ......................................................................................................................30

Assumptions
Administrators are already registered into the system. New administrators can register by only exist administrators if needed. Administrators would allow deleting any users form the system. Employees passwords are entered by the HR and HR managers passwords entered by the administrator to the system. But after entered they dont have to permission to accesses those passwords. All the users of this system have a basic knowledge of using computers and experienced in working with console applications. Users are work on only Widows based platforms.

Further Programming Concepts in C++

Designing the Solution


This application is implemented by using C++ language concepts with object oriented concepts. UML concepts worked as an intermediate between C++ and the object oriented concepts. Unified modeling language help to map those concepts together as well as it help to design a model of business and application logics. Basically UML help to identify the entities /actors of a proposed system and separate the concepts of their attributes and behaviors. Those attributes and behaviors are more important when it comes to model the real system. The relationship between each entity of the system, separate their common and unique attributes and other special functionalities can be performed. Search employee is the major functionality that can be performs using user attributes. Considering above concepts, several user levels can be define for this proposed application. HR manager, Administrator and employee are the main categories. There are several categories under employee such as managing director, senior manager, manager, senior executive, executive and junior executives. Security issue is the most important factor for the organizations. Therefore the proposed solution needs to provide high security mechanisms. Saving data using binary coded system encrypt passwords and encrypt sensitive data mechanisms would provide by the implemented system to achieve safety of the data with using proper access modifiers. Easy navigability and user friendly systems should help users to perform day to day operations easily. To improve those features user manual would provide by the system. It shows how to use each functionalities of the system. High level authority would use the proposed system vastly. Therefore user manual feature mainly focus on HR and Admin levels. Validations would avoid the mistakes that can happen from the users. Each and every functionality implement with high level validation to achieve those. 3

Further Programming Concepts in C++ Implementing applications using object oriented concepts help to easily expand, implement new features as further enhancements. To help with this, the proposed application used class organization methods to separate header and body of a class. Therefore its enable to developers to understand the program code as well.

Further Programming Concepts in C++

Class Diagram
Data files
* adm DAT file in HR DAT file em ployee DAT file * -End 5 File _handling -E 6 nd +write _to_file () +read _from _file () +search _by_nam () e +search _by_IC() +search _by_staff _no () +search _by_designation () +search _by_departm ent () +search _by_joined _date () +search _by_DO () B +edit () +delete ()

-End 3 *

database

-E nd1

-End 3

User

Business Logic

#nam : char e #staff no : int #IC no : char #gender : char #designation : char #departm ent : char #date _joined : char #DO : char B +setInfo () : void +view _profile () : void +logout () : void * -End 4

-End 2

Hierarchical Inheritance
adm in +reg_HR () : void +search _HR_by_nam () : void e +search _HR_by_staff _no () : void +search _HR_by_DO () : void B +search _HR_by_joined _date () : void +search _HR_by_ICno () : void +edit _HR() : void +delete _HR() * * adm _controller in * +reg _HR() +view _all _hr() +search _by_hr_ nam () e +search _by_HR_IC() +search _by_staff _no () +view _profile () +edit _hr() +delete _hr() -End 8 -End 7 -E 8 nd em ployee * -End 4 HR

+Reg _em () : void p +search _em _by_nam () : void p e +search _em _by_ICno () : void p +search _em _by_staff _no () : void p +search _em _by_designationo () : void p +search _em _by_departm p ent () : void +search _em _by_DO () : void p B +search _em _by_joined _date () : void p +edit _em () : void p +delete _em () : void p -End 7 * * -End 8 HR_controller +em _reg () p +view _all _em () p +search _by _em p +search _by _em p +search _by _em p +search _by _em p +view _profile () +edit _em () p +delete _em () p

controllers
* * -End 7 -End 7 G _controller UI +login _as_adm () in +login _as_hr() +login _A _em s ployee () * -End 8 * -End 7

_nam () e _IC() _desig () _dep ()

* G UI

-E 8 nd

-E 7 nd +add _to_reg() +adm _m in enu () +HR _m enu () +em ployee _m enu () * login -End 8 * +get _usernam () e +get _password () +get _Designation () +error _checking ()

Interface

Further Programming Concepts in C++

UML Concepts (Local Design)


Association
Association describes the reasons for the relationship between each class. Using association can describe the design decisions that you made about classes in your application and the navigability of application. Using of three tier architecture in the proposed application can be explained easily with association relationship. In the class diagram an association appears as a solid line between two classifiers.

Composition
Represents wholepart relationships among the classes. It specifies the lifetime of the part classifier according to its whole classifiers lifetime. In other words it is explain the dependability of this relationship. In a composition relationship, data usually flows in only one direction. It is from the whole classifier to the part classifier. In the class diagram, composition relationship appears as a solid line with a filled diamond at the whole classifier side.

Generalization
Generalization relationship is a relationship that represents the inheritance in UML. The common attributes and methods can be placed in parent class and can reuse them in one or more child model elements. Only distinct attributes and operations from the parent can define as the child features. In the class diagram represent the generalization relationship with solid line with a arrowhead that points from the child model element to the parent model element. IBM. (2005)

Further Programming Concepts in C++

Object Oriented Concepts


Objects
Objects are the abstract representations of the real world things. The thing can be a physical presence or an abstract concept. Therefore using object in a program implementation can touch the real world scenarios. Each object has the unique identity and keeps the attributes and behaviors. In other word objects are the instances of the classes. Class definition would provide below explanation. Several objects are used in proposed application. There can be creating more than one object for a class. Except user class, every class has its own objects. The reasons for not having objects in user class briefly explain under abstract class topic.

Balagurusamy (2008)

Further Programming Concepts in C++

Classes
Classes hold the objects with the same characteristics and behaviors. Allow sharing common features among its objects. The table shows the classes of proposed application. Class name User Employee Class type Base class (abstract class) Derived class Purpose Keep the generic information about users. Keep lower level employees information and provide basic functionalities. Keep information about HR managers and provide HR managers major functionalities. Keep information about Administrators and provide their major functionalities. Provide file input/output operations.

HR

Derive class

Admin

Derive class

File class

handling Template class

Support classes Login GUI GUI controller Common Class Class Class Class Authorization of users to the system. Get all the details from the user. Control the user inputs. Hold the common features of the user.

User class is implemented as abstract class and HR, admin and employee classes are derive from it. Those classes are sharing the attributes and methods of user class. There are other support classes also. 8

Further Programming Concepts in C++ All these classes are organized according to three tier architecture. It means provide three ways to interact for client, server and environment each other. User interfaces are stored in the client side and business and application logics are store in separate server and database are in a different server. The reason is to separate each processes and changes may not affect to different tiers. Therefore it is easy to reuse the exist code without affecting to the whole system. Annon. (n.d)

Inheritance
The creation of one class by extending from another existing class called Inheritance. Instances of new class should inherit all features of parental class. There are several Inheritance types in C++ language. Among those Hierarchical Inheritance is used for proposed application. Using Inheritance is more beneficial in several ways. It promotes the class reusability, can define the differences between related classes, save the time and effort of redoing the same work. In this proposed application Inheritance is the major fragment. All the processers depend on the Inheritance concepts. All the classes that represent users of the system such as Administrator, HR Manager and all other employees are inherited from a common class which has the basic substance for creating users. The user class act as the parent class and others are act as child classes. Deitel, H. & Deitel, P. (2009), Balagurusamy (2008)

Polymorphism
One of major fragment of an Object Oriented concept is the Polymorphism. A single operation can have different behavior in different objects is called Polymorphism. It is

Further Programming Concepts in C++ provide functions, and classes in many different forms. There are two common ways to implementing this concept. Overloading Using the same method name with different parameter type lists is called overloading. In this project all the classes which are inherit from the user class have overloaded constructor. And in the main menu use the overloaded functions to direct the sub menus according to users selections. Overriding Using different implementation of the same method in sub classes is called overriding. In this application sub classes have their own implementation of the parent class methods. The view profile method and the exit methods are inherit from the user class and act as the same in each class and therefore override these methods in sub classes. In C++ concepts of pure virtual functions have been used to implement this feature. According to Deitel & Deitel (2009) another way to implement Polymorphism is to use templates. For proposed application special template class is used to handle file input and output operations. It is simplify the complexity of file handling process and avoid the repeating block of codes. Deitel, H. & Deitel, P. (2009)

Encapsulation
Encapsulation is the process of protecting data by hiding from various views. According to Balaguruswamy (2008) C++ provide three kinds of encapsulation methods which called access modifiers. Private, public and protected are those. 10

Further Programming Concepts in C++ In this project data encapsulation is done using all accesses modifiers available in C++. To hide sensible data such as usernames and passwords used private access modifier. Inheritance can be achieved using protected and all methods are define as public to allow using those in anywhere in the application.

Balagurusamy (2008)

Implementation
C++ Libraries
To implement proposed application following C++ libraries are used. 11

Further Programming Concepts in C++ Iostream - handle input/ output Ctype - character handling Cstring manipulate C string and arrays Ctime manipulate date and time Cstdlib converting data types Cstdio interact streams with physical devices cplusplus.com. (2000)

Iostream
Provides input and output functionality using streams. Under iostream library following functions are used.

Cin Cout Setw Ios Fstream

cplusplus.com. (2000)

12

Further Programming Concepts in C++

Ctype
All character handling functions are under Ctype library. Following functions are used.

Isalpha Isdigit Isupper Islower Ispunct Isspace cplusplus.com. (2000)

Cstring
Strcpy Strlen Strcmp cplusplus.com. (2000)

Ctime
Clock 13

Further Programming Concepts in C++ Clock_t cplusplus.com. (2000)

cstdlib
Atoi Exit cplusplus.com. (2000)

cstdio
Getchar fflush

cplusplus.com. (2000)

14

Further Programming Concepts in C++

Validations
Validations are used to decrease the mistakes that can be done by the uses. It is the best way to secure users and hide the complexity of the implementation and program application from the users. Validations must require using to provide more user friendly applications. Following describe the validations that used for proposed application.

Login Validations

Users unable to log in to the system without correct login details. They need authorized passwords and usernames to access the system.

Username Validations

Usernames are unique and cannot have duplications. Therefore when registering new user, system will check the availability of new username. Usernames are help to identify the user levels of the employees. Administrators username must begin with letter A or a and HRs username must begin with letter H or h and rest of the other employees usernames must begin with the letter E or e. Password Validations

Due to security reasons several security mechanisms applied to validate passwords. Password hiding mechanism is use when authorized users entering their passwords in to the console application. Rather displaying what they enter to the console, system will print the * symbol to hide sensitive information.

15

Further Programming Concepts in C++ Users require registering with highly robust passwords. Password must include digits, upper case letters, lower case letters and punctuations. If user entered password without one of the pre-requisites, system will generate error massage that saying weak password and give another chance to enter. System will check and wait until entering the strong password. After satisfy the pre-requisites of a password, system automatically encrypt the password and save in to the corresponding file. When require retrieving the password, system perform the decryption mechanism automatically and provide it as the original format. As encryption mechanism system used the reverse mechanism and for decryption vice versa. IC Number Validations

IC Number should be including with nine digits and V or v as final character. System will wait until enterer right format IC Number with providing error message saying wrong input.

Designation Validation

Designation should be one of the following. HR or hr ADMIN or admin MANAGING DIRECTOR or managing director SENIOR MANAGER or senior manager MANAGER or manager 16

Further Programming Concepts in C++ SENIOR EXECUTIVE or senior executive EXECUTIVE or executive JUNIOR EXECUTIVE or junior executive

If user enters except above details, system will provide error massage that saying wrong input.

Gender Validations Users require register with their gender. To represent females can enter female, FEMALE, F or f. And to represent males can input MALE, male, M or m. Except those system will ignore other inputs.

Department Validations Department can be one of the following. HR or hr MARKETING or marketing SALES or sales. IT or it ACCOUNT or account

Except those system will ignore other inputs. 17

Further Programming Concepts in C++ Date Validations Both Joined date and date of birth cannot reach the current date. Both dates need to satisfy the format of mm/ dd/ yy . And also require to satisfy with general requirements such as dates should be less than or equal to the 31 and months should be less than or equal to the 12. After satisfy all above requirements system will allow to save the both dates.

Marital Status Validation To represent married employees can use married, MARRIED, M or m. And to represent unmarried employees can use SINGLE, SINGLE, S or s. System will wait until enterer one of the above.

Character Validation If user enters numbers rather characters to the name, nationality and religion fields system will ignore them with providing error massage. Only characters will accept for those.

Menu Validation

If user enter any number or character that not in main menu system will provide error massage.

File Validations 18

Further Programming Concepts in C++ If user enter invalid input that not in the files (database) system will provide error massages.

19

Further Programming Concepts in C++

Special Features

User Manual

To increase the user friendliness of the application user manual is provided.

It

provides the details of how to use application, required formats for each inputs and example for each. Mainly this feature provided for HR and admin of the system. Because they are the people who highly involve with this application.

For the ease of use, user manual will automatically loaded, after log in to the system. And also they can use user manual menu anytime according to their needs.

Error massages

Proper error messages are provided to avoid confusing users. Anyone can read and understand what was happen and give ability to back to the system. Auto generating Staff Number

Staff numbers are auto generated and provide when required. HR and administrator does not need to enter them manually.

Check for availability

Once new user will enter to the system, availability will be checking to ensure the uniqueness of valuable data. This feature will apply for username, IC number and staff number. 20

Further Programming Concepts in C++

Screens

Login Screen

User Manual Screen

21

Further Programming Concepts in C++

Main Menu

Register Menu 1

22

Further Programming Concepts in C++

Register Screen with validations

Edit / Update Screen

23

Further Programming Concepts in C++

Test Plans
ID 01. Login 02. Login 03. Login 04. 05. Register HR 06. Register HR 07. Register HR 08. Register HR 09. Register HR 10. Register HR 11. Register HR 12. Register HR 13. Register HR (Administrator Main menu) View profile Select View profile Add a new HR with valid details Add a new HR with invalid name(include digits) Add a new HR with invalid username Add a new HR with invalid password Add a new HR with invalid designation Add a new HR with invalid IC number Add a new HR with invalid gender Add a new HR with invalid department Add a new HR with invalid DOB 24 Initial State Test Valid username/password /Designation Invalid username/password/ Designation Kept blank Excepted Outcome Login success, welcome menu and main menu Login failed error massage. Login failed error massage. Admin profile details HR added successful massage Wrong input error massage Wrong input error massage Weak password error massage Wrong input error massage Wrong input error massage Wrong input error massage Wrong input error massage Wrong format error massage

Further Programming Concepts in C++

14. 15.

Register HR Search HR

Add a new HR with invalid marital status Select Search HR Enter exist name (authorized name) Enter not exist name

Wrong input error massage View sub menu View details Wrong input error massage View details Wrong input error massage View details Wrong input error massage View details Wrong input error massage View details Wrong input error massage View details Wrong input error massage Confirm massage If yes successful If no-not edited message

16. Search by name 17. Search by name 15. Search by IC number 16. Search by IC number 17. Search by designation 15. Search by designation 16. Search by staff no 17. Search by staff no 15. Search by department 16. Search by department 17. Search by joined date Search by joined date 16. Edit HR

Enter exist IC number Enter not exist IC number Enter exist designation Enter not exist designation Enter exist staff no Enter not exist staff no Enter exist department Enter not exist department Enter exist joined date Enter not exist joined date Edit required exist details

25

Further Programming Concepts in C++ 17. 15. Edit HR Delete HR Enter not exist name Select details Wrong input error massage Confirm massage If yes successful If no-not deleted message Show details Exit from application HR profile details employee added successful massage Wrong input error massage Wrong input error massage Weak password error massage Wrong input error massage Wrong input error massage Wrong input error massage Wrong input error massage Wrong format error massage Wrong input error massage View sub menu

16. 17. 04. 05.

User manual Log out (HR Main menu) View profile Register employee

Select menu Select log out Select View profile Add a new employee with valid details Add a new employee with invalid name(include digits) Add a new employee with invalid username Add a new employee with invalid password Add a new employee with invalid designation Add a new employee with invalid IC number Add a new employee with invalid gender Add a new employee with invalid department Add a new employee with invalid DOB Add a new employee with invalid marital status Select Search employee 26

06. Register employee 07. Register employee 08. Register employee 09. Register employee 10. Register employee 11. Register employee 12. Register employee 13. Register employee 14. Register employee 15.

Further Programming Concepts in C++ Search employee 16. Search by name 17. Search by name 15. Search by IC number 16. Search by IC number 17. Search by designation 15. Search by designation 16. Search by staff no 17. Search by staff no 15. Search by department 16. Search by department 17. Search by joined date Search by joined date 16. Edit employee 17. Edit employee 15. Select details 27 Enter not exist name Enter not exist joined date Edit required exist details Wrong input error massage Confirm massage If yes successful If no-not edited message Wrong input error massage Confirm massage Enter not exist department Enter exist joined date Wrong input error massage View details Enter exist department Enter not exist staff no Wrong input error massage View details Enter not exist designation Enter exist staff no Wrong input error massage View details Enter exist designation Enter not exist IC number Wrong input error massage View details Enter exist IC number Enter exist name (authorized name) Enter not exist name View details Wrong input error massage View details

Further Programming Concepts in C++ Delete employee 16. 17. User manual Log out Select menu Select log out If yes successful If no-not deleted message Show details Exit from application

Limitations
Only can keep limited number of medical records. Difficult to move for databases. 28

Further Programming Concepts in C++ Difficult to access files in simultaneously. Difficult to change and expand the application. Because it can be affect to current data files. Security issues can occur. Data corrupting can be increase when try to access files for different functionalities.

29

Further Programming Concepts in C++

References
IBM. 2005. Rational Software Architect . [ONLINE] Available at:http://publib.boulder.ibm.com/infocenter/rtnlhelp/v6r0m0/index.jsp?topic= %2Fcom.ibm.xtools.modeler.doc%2Ftopics%2Fcassn.html. [Accessed 20 October 11]. IBM. 2005. Rational Software Architect : Composition relationships. [ONLINE] Available at:http://publib.boulder.ibm.com/infocenter/rtnlhelp/v6r0m0/index.jsp?topic= %2Fcom.ibm.xtools.modeler.doc%2Ftopics%2Fcassn.html. [Accessed 20 October 11]. Annon.. n.d. Three-tier Client/Server. [ONLINE] Available at: http://computer.yourdictionary.com/three-tier-client-server. [Accessed 21 October 11]. cplusplus.com. 2000. C++ Reference. [ONLINE] Available at: http://www.cplusplus.com/reference/. [Accessed 20 October 11]. Balagurusamy (2008), Object Oriented Programming With C++, India: TATA McgrawHill. Cain, J. (2010), Programming Abstractions - CS106B: California: Stanford University. Deitel, H. & Deitel, P. (2009), C++ How to Program, USA: Prentice Hall. Hekmat, S. (n.d), C++ Essentials, PragSoft Corporation.

30

Further Programming Concepts in C++

31

You might also like