Assignment 2 Assignment goals The story Suggested design

  • Slides: 39
Download presentation
Assignment 2 • • Assignment goals The story Suggested design (one of many) Specification

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

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

Your assignment must: have a working Makefile. Compile and run. generate reports using the

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

Assignment 2 • • Assignment goals The story Suggested design (one of many) Specification

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

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 Logger • Read

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

System Overview Main Initialization the system For each day add candidates and job openings

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 Job. Opening (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

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: Cand 1 We read (past) candidates up until here. …. Cand 6 – Will be read at 17/03/10 Cand 7 - Will be read at 17/03/10 Cand 8 - Will be read at 18/03/10 Cand 9 - Will be read at 18/03/10 Cand 10 - Will be read at 19/03/10. .

HRC filtering: HRC sends a candidate to a job opening, based on the following

HRC filtering: HRC sends a candidate to a job opening, based on the following criteria only: 1. The job type is desired by the candidate. 2. The candidate has the set of skills for the job. HRC Strategy: 1. Eager: Will send all qualified candidates to a job. 2. 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

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: 1. Cheap – Will hire the cheapest programmer. 2. Lavish – Will hire the more talented programmer. 3. 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 10 K. If he doesn’t

Candidate Compromises (Example): Suppose Henry expects a salary of 10 K. If he doesn’t find a job after 30 says, will compromise for 9 K. If he doesn’t find a job after 60 says, will compromise for 8 K. If he doesn’t find a job after 90 says, will compromise for 7 K. 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 7 k). Exact details can be found at section 7.

Reports: In case of a job placement, we remove the candidate, and job opening

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

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

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

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

3 rd 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 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

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 (const Coffee& c) Coffee& operator =(const Coffee &c) …… Class Tea()

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

Compilation Class Coffee() Coffee (const Coffee& c) Coffee& operator =(const Coffee &c) …… Class

Compilation Class Coffee() Coffee (const Coffee& c) Coffee& operator =(const Coffee &c) …… Class Tea() Tea (const Tea& c) Tea& operator =(const Tea &c) …… Coffee. o 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 Class Coffee() Coffee (const Coffee& c) Coffee& operator =(const Coffee &c) …… Class

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

Link errors Class Coffee() Coffee (const Coffee& c) Coffee& operator =(const Coffee &c) ……

Link errors Class Coffee() Coffee (const Coffee& c) Coffee& operator =(const Coffee &c) …… Make. Coffe() Class Tea() Tea (const Tea& c) Tea& operator =(const Tea &c) …… … make. Coffe(int sugar); … Coffee. o Tea. o Main. o Run. cpp Main Coffe. House Executable

External Lib Class Coffee #include “Espresso. h” Coffee() Coffee (const Coffee& c) Coffee& operator

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

Compilation Class Coffee #include “Espresso. h” Coffee() Coffee (const Coffee& c) Coffee& operator =(const

Compilation Class Coffee #include “Espresso. h” Coffee() Coffee (const Coffee& c) Coffee& operator =(const Coffee &c) Make. Espresso(); …… Class Tea() Tea (const Tea& c) Tea& operator =(const Tea &c) …… Espresso. h Somebody else implemented Coffee. o Tea. o Main. o 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 Class Coffee #include “Espresso. h” Coffee() Coffee (const Coffee& c) Coffee& operator =(const

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

Class Coffee #include “Espresso. h” Coffee() Coffee (const Coffee& c) Coffee& operator =(const Coffee

Class Coffee #include “Espresso. h” Coffee() Coffee (const Coffee& c) Coffee& operator =(const Coffee &c) Make. Espresso(); …… Class Tea() Tea (const Tea& c) Tea& operator =(const Tea &c) …… Espresso. h Somebody else implemented Link lib. Espresso. so Coffee. o Tea. o Main. o Run. cpp Main Coffe. House Executable

Class Coffee #include “Espresso. h” Coffee() Coffee (const Coffee& c) Coffee& operator =(const Coffee

Class Coffee #include “Espresso. h” Coffee() Coffee (const Coffee& c) Coffee& operator =(const Coffee &c) Make. Espresso(); …… Class Tea() Tea (const Tea& c) Tea& operator =(const Tea &c) …… Espresso. h Somebody else implemented Execute lib. Espresso. so Coffee. o Tea. o Main. o Run. cpp Main Coffe. House Executable

Assignment 2 • • Assignment goals The story Suggested design (one of many) Specification

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

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“ // Tom. h

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

Avoid including in the headers. // Boy. h // Tom. h // Forward declarations

Avoid including in the headers. // Boy. h // Tom. h // Forward declarations class Tom; // Forward declarations class Boy; class Boy { public: Boy(); Tom* tom; } class Tom { public: Tom(); Boy* boy; } // 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

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

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

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