1 / 39

Assignment 2

This assignment aims to design an object-oriented system in C++ using standard STL-based data structures and a third-party library. The assignment also focuses on memory handling in C++ and includes tests to check the implementation.

heideman
Download Presentation

Assignment 2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Assignment 2 • Assignment goals • The story • Suggested design (one of many) • Specification Questions • POCO and revisit completion in C++ • Good habits • Questions • Whats now?

  2. Assignment Goals • design an object-oriented • experience in C++ • standard STL-based data-structures and 3rd party library • handle the memory in C++ • tests to check your implementation (CppUnit is optional and recommended)

  3. Your assignment must: have a working Makefile. Compile and run. generate reports using the supplied class. must notcrush when it runs from the console on the lab's. Testing . . .

  4. Assignment 2 • Assignment goals • The story • Suggested design (one of many) • Specification Questions • POCO and revisit completion in C++ • Good habits • Questions • Whats now?

  5. Assignment 2 • Assignment goals • The story • Suggested design (one of many) • Specification Questions • POCO and revisit completion in C++ • Good habits • Questions • Whats now?

  6. Initialization of the system: • Init logger • Create the HRC • Read Companies • Read Start Date. • Read events (candidates, job opening. The number to read is defined by INIT_XXX_NUM. Logger Job Opening • Job Opening Adding Candidates CCCCCCCCC….. Job Opening Adding Job Openings OOOOOOO….. The HRC Matches Candidates to Job Openings. Matching Between Candidates and Jobs MMMMMMM….. Candidate Candidate Report RRRRR…. • Candidate

  7. System Overview Main Initialization the system For each day add candidates and job openings (each addition is associated with a date). match loop reports The Match For each JobOpening (ordered by Date and SN). send a batch of candidates Acceptance to the company is derived from the strategy, the company applies. If a placement is done, remove the corresponding candidate and job opening. Also record the event for the reports (e.g., Salary Survey).

  8. Reputation The rate at which HRC reads the candidates and job openings is defined by Seeker_Rep and Company_Rep respectively. Details can be found at Section 5. Example: Seeker_Rep = 2. Current Date = 17/03/10. Candidates File: Cand1 …. Cand6 – Will be read at 17/03/10 Cand7 - Will be read at 17/03/10 Cand8 - Will be read at 18/03/10 Cand9 - Will be read at 18/03/10 Cand10 - Will be read at 19/03/10 .... We read (past) candidates up until here.

  9. HRC filtering: • HRC sends a candidate to a job opening, based on the following criteria only: • The job type is desired by the candidate. • The candidate has the set of skills for the job. • HRC Strategy: • Eager: Will send all qualified candidates to a job. • Fair: For new jobs, the HRC will send only candidates that have waited more than others. (The exact definition is given in 6.1.1).

  10. Companies filtering: • Each company has a QLmin, a candidate that has an average skill level, below this threshold will be rejected. • The raison d'être for this parameter, is to allow companies the ability not to accept any candidate at all. • Companies Strategy: • Cheap – Will hire the cheapest programmer. • Lavish – Will hire the more talented programmer. • Cost Effective – Will generate a weight function (explained in 6.2.3) and will hire the candidate with the lowest value of this function.

  11. Candidate Compromises (Example): Suppose Henry expects a salary of 10K. If he doesn’t find a job after 30 says, will compromise for 9K. If he doesn’t find a job after 60 says, will compromise for 8K. If he doesn’t find a job after 90 says, will compromise for 7K. If he doesn’t find a job after 120 says, he will look for a job as a TA in spl. (just kidding, he will compromise for 7k). Exact details can be found at section 7.

  12. Reports: In case of a job placement, we remove the candidate, and job opening from the pool (The candidate will not be sent to new jobs, and the job will not receive more candidates). But we keep a record of them somewhere, and of the commission the company paid. So we can produce the reports defined in section 4.5. (This is NOT an implementation guide, it’s up to you where and how to store the job openings, and candidates)

  13. Assignment 2 • Assignment goals • The story • Suggested design (one of many) • Specification Questions • POCO and revisit completion in C++ • Good habits • Questions • Whats now?

  14. Assignment 2 • Assignment goals • The story • Suggested design (one of many) • Specification Questions • POCO and revisit completion in C++ • Good habits • Questions • Whats now?

  15. 3rd party library The programmer POCO, ACE, BOOST OS: Windows, Mac, Linux, Solaris, SGI, etc

  16. POCO To install POCO on your machine follow the instructions given in here. Linux: POCO installs it’s libraries in /usr/local/lib. Run the following command: sudo ldconfig /usr/local/lib This will enable the run-time linker to find the POCO libraries.

  17. POCO Windows: If you gen an error of a missing dll file. You can solve it by adding the appropriate directory (<poco-directory>/bin) to the environment variable named “Path”. Or you can simply copy the required dll file to the directory of your executable

  18. Class Coffee Coffee() Coffee (const Coffee& c) Coffee& operator =(const Coffee &c) …… Where do I put the Main? Class Tea Tea() Tea (const Tea& c) Tea& operator =(const Tea &c) …… Run.cpp Main Run.cpp Main

  19. Compilation Coffee.o Class Coffee Coffee() Coffee (const Coffee& c) Coffee& operator =(const Coffee &c) …… Class Tea Tea() Tea (const Tea& c) Tea& operator =(const Tea &c) …… Tea.o Main.o Now can I run my software? Run.cpp Main g++ -g -Wall -Weffc++ -c -o Debug/Coffe.o src/Coffe.cpp g++ -g -Wall -Weffc++ -c -o Debug/Tea.o src/Tea.cpp g++ -g -Wall -Weffc++ -c -o Debug/Run.o src/Run.cpp

  20. Link Coffee.o Class Coffee Coffee() Coffee (const Coffee& c) Coffee& operator =(const Coffee &c) …… CoffeHouse Executable Class Tea Tea() Tea (const Tea& c) Tea& operator =(const Tea &c) …… Tea.o Main.o Run.cpp Main g++ -o Debug/CoffeHouse Debug/Coffe.o Debug/Tea.o Debug/run.o

  21. Link errors Coffee.o Class Coffee Coffee() Coffee (const Coffee& c) Coffee& operator =(const Coffee &c) …… MakeCoffe() CoffeHouse Executable Tea.o Class Tea Tea() Tea (const Tea& c) Tea& operator =(const Tea &c) …… … makeCoffe(int sugar); … Main.o Run.cpp Main

  22. External Lib Class Coffee #include “Espresso.h” Coffee() Coffee (const Coffee& c) Coffee& operator =(const Coffee &c) MakeEspresso(); …… Class Tea Tea() Tea (const Tea& c) Tea& operator =(const Tea &c) …… But where can I find Espresso.h? Run.cpp Main Espresso.h Somebody else implemented

  23. Compilation Class Coffee #include “Espresso.h” Coffee() Coffee (const Coffee& c) Coffee& operator =(const Coffee &c) MakeEspresso(); …… Coffee.o Tea.o Class Tea Tea() Tea (const Tea& c) Tea& operator =(const Tea &c) …… Main.o Run.cpp Main Espresso.h Somebody else implemented g++ -g -Wall -Weffc++ -c -o Debug/Coffe.o src/Coffe.cpp g++ -g -Wall -Weffc++ -c -o Debug/Tea.o src/Tea.cpp g++ -g -Wall -Weffc++ -c -o Debug/Run.o src/Run.cpp

  24. Link Class Coffee #include “Espresso.h” Coffee() Coffee (const Coffee& c) Coffee& operator =(const Coffee &c) MakeEspresso(); …… Coffee.o CoffeHouse Executable Tea.o Class Tea Tea() Tea (const Tea& c) Tea& operator =(const Tea &c) …… Main.o But where is MakeEsspresso()? Run.cpp Main Espresso.h Somebody else implemented

  25. Link Class Coffee #include “Espresso.h” Coffee() Coffee (const Coffee& c) Coffee& operator =(const Coffee &c) MakeEspresso(); …… libEspresso.so Coffee.o CoffeHouse Executable Tea.o Class Tea Tea() Tea (const Tea& c) Tea& operator =(const Tea &c) …… Main.o Run.cpp Main Espresso.h Somebody else implemented

  26. Execute Class Coffee #include “Espresso.h” Coffee() Coffee (const Coffee& c) Coffee& operator =(const Coffee &c) MakeEspresso(); …… libEspresso.so Coffee.o CoffeHouse Executable Tea.o Class Tea Tea() Tea (const Tea& c) Tea& operator =(const Tea &c) …… Main.o Run.cpp Main Espresso.h Somebody else implemented

  27. Assignment 2 • Assignment goals • The story • Suggested design (one of many) • Specification Questions • POCO and revisit completion in C++ • Good habits • Questions • Whats now?

  28. Good Habits • Always consider if you should write copy constructor and copy assignment operator. • Avoid using “using namespace” in the header. • Avoid including in the headers. • Try to write short functions. • Every new must follow delete. • Consider using smart pointers.

  29. Avoid including in the headers. // Boy.h #include“Tom.h“ classBoy { public: Boy(); Tom tom; } // Tom.h #include“Boy.h“ classTom { public: Tom(); Boy boy; }

  30. Avoid including in the headers. // Tom.h // Forward declarations classBoy; classTom { public: Tom(); Boy* boy; } // Boy.h // Forward declarations classTom; classBoy { public: Boy(); Tom* tom; } // Boy.cpp #include“Boy.h“ #include“Tom.h“ // Boy.cpp #include“Tom.h“ #include“Boy.h“

  31. Implementation Requirements Each data piece should be held exactly once. Memory Leak Object-oriented, Well documented, Good Style Makefile and assignment tree Testing

  32. Assignment 2 • Assignment goals • The story • Suggested design (one of many) • Specification Questions • POCO and revisit completion in C++ • Good habits • Questions • Whats now?

  33. Assignment 2 • Assignment goals • The story • Suggested design (one of many) • Specification Questions • POCO and revisit completion in C++ • Good habits • Questions • Whats now?

More Related