Hi Guys
The thing is that i was asked to make a libaray database managment software for my semester project which i did but now my teacher is asking to give that same project in OOP and i am really bad in that.Can anyone change my program into Object orientied programming ?I have no time left

Recommended Answers

All 5 Replies

It would stand to reason that the teacher had taught you how to do this before making the assignment. If you have a working program, modifying it to be object oriented should not be so difficult, as long as you put some thought into it.
Why would you expect somone else to write it for you?

Also, you shouldn't be using GOTO. The teacher should have failed you for that alone.

commented: Ok what do you suggest me to use ? +0

This is not what they mean by Delegation Principle.

Obviously no one will redesign your application to comply with OO principles for you.

You can start making your application OO by implementing the first five principles (S.O.L.I.D.).

  • Single Responsibility Principle - Each class should have its own responsibility. For instance a Book class does not contain Student information.

  • Open Closed Principle - Each class should be open for extension and closed to modification. For instance if you want to add a new book type that can only be read in the library but not lent out you do not want to have to modify the Book class. Instead you'll create something like a LibraryItem which Book extends. Later on you can then add a ReadOnlyBook as an extension as well.

  • Liskov Substition Principle - Objects should be replacable by instances of their subtypes. For instance if you have a LibraryItem, and Book extends LibraryItem, then in every place where you use LibraryItem you must be able to replace it with a Book instance and not alter the behaviour of your application.

  • Interface Segregation Principle - Interfaces should be specific to their clients. For instance if you had a ScannableItem interface, which could be a book, video or library card, you would only force methods/functions that are applicable, like scan(), and not something like read() or watch() which are specific to items and should be in their own interfaces. Otherwise you'd be forced to implement empty variations in items that can't be watched or read.

  • Dependency Inversion Principle - Depend upon abstractions, not concretions. For instance a LibraryScanner class should not know whether the item being lent out is a Book, Video or Magazine, but instead communicate to it via a common interface like Item (which could force a method like getPrice()). That way if you add a new item you don't have to change Library, and if you change Library you don't have to change Book, Video or Magazine. Their only dependency is via the interface Item.

So in conclusion I would start by chopping up the application into responsibilities (on paper/uml/diagram/napkin). Then establish where the classes will "touch" and put interfaces inbetween to decouple them (think Item interface for Book, Video to put between a LibraryScanner class etc.). It's always a good idea to check if any Design Patterns can be applied to the result, which can lead to some extra classes/interfaces.

Once you have that in an image, start by applying the changes to the code. Remove entities from the large class and put them in their own classes, which extend/implement the proper abstraction (a Book that implements Item for instance). Then split up the logical parts. For instance, inventory management and scanning/returning can be separated. A Scanner class could then ask an Inventory class (or even better, their interfaces!) to add/remove a book (Item!) that has been scanned. Other parts that could be separated are the student management, the user input and so on.

Even if you run out of time now, it will be good practice to apply OO to this when you have some time to spare. That way, in the future, you'll be able to start designing in OO from the start and won't have to spend all that time afterwards to change it.

Can you tell me any good website or tutorial videos so i can improve my OO Skills ?

Why don't you start fresh and code a little name, phone_number and email type data base?

You could use a C++ vector container to hold all the data records (objects)

You might start out with something like this:

class Person
{
public:
    Person( const string& name="", const string& phone="", const string& email="" )
    : name(name), phone(phone), email(email) {}
    // other stuff //
private:
    string name;
    string phone;
    string email;
} ;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.