390 likes | 566 Views
Assignment 2. Assignment goals The story Suggested design (one of many) Specification Questions POCO and revisit completion in C++ Good habits Questions Whats now?. Assignment Goals. design an object-oriented experience in C++
E N D
Assignment 2 • Assignment goals • The story • Suggested design (one of many) • Specification Questions • POCO and revisit completion in C++ • Good habits • Questions • Whats now?
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)
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 . . .
Assignment 2 • Assignment goals • The story • Suggested design (one of many) • Specification Questions • POCO and revisit completion in C++ • Good habits • Questions • Whats now?
Assignment 2 • Assignment goals • The story • Suggested design (one of many) • Specification Questions • POCO and revisit completion in C++ • Good habits • Questions • Whats now?
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
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).
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.
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).
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.
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.
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)
Assignment 2 • Assignment goals • The story • Suggested design (one of many) • Specification Questions • POCO and revisit completion in C++ • Good habits • Questions • Whats now?
Assignment 2 • Assignment goals • The story • Suggested design (one of many) • Specification Questions • POCO and revisit completion in C++ • Good habits • Questions • Whats now?
3rd party library The programmer POCO, ACE, BOOST OS: Windows, Mac, Linux, Solaris, SGI, etc
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.
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
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
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
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
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
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
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
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
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
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
Assignment 2 • Assignment goals • The story • Suggested design (one of many) • Specification Questions • POCO and revisit completion in C++ • Good habits • Questions • Whats now?
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.
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; }
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“
Implementation Requirements Each data piece should be held exactly once. Memory Leak Object-oriented, Well documented, Good Style Makefile and assignment tree Testing
Assignment 2 • Assignment goals • The story • Suggested design (one of many) • Specification Questions • POCO and revisit completion in C++ • Good habits • Questions • Whats now?
Assignment 2 • Assignment goals • The story • Suggested design (one of many) • Specification Questions • POCO and revisit completion in C++ • Good habits • Questions • Whats now?