assignment 2 assignment goalsassignment goals the story suggested design (one of many) specification...

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

Post on 22-Dec-2015

217 views

Category:

Documents


0 download

TRANSCRIPT

Assignment 2• Assignment goalsAssignment 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 not crush when it runs from the console on the lab's.

Testing . . .

Assignment 2• Assignment goals• The storyThe 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)Suggested design (one of many)• Specification Questions• POCO and revisit completion in C++• Good habits• Questions• Whats now?

Job Opening

Job Opening

Job Opening

Candidate

Candidate

Candidate

Matching Between Candidates and Jobs

MMMMMMM…..

Report

RRRRR….

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

Adding Job Openings

OOOOOOO…..

Adding Candidates

CCCCCCCCC…..

The HRC

Matches Candidates to Job

Openings.

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).

Main

Initialization the system

For each day

add candidates and job openings (each addition is associated with a date).

match loop

reports

System Overview

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:

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 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 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 QuestionsSpecification 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++POCO and revisit completion in C++• Good habits• Questions• Whats now?

3rd party library

OS: Windows, Mac, Linux, Solaris, SGI, etcOS: Windows, Mac, Linux, Solaris, SGI, etc

POCO, ACE, BOOSTPOCO, ACE, BOOST

POCOTo 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.

POCOWindows:

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

&c)……

Class TeaTea()Tea (const Tea& c)Tea& operator =(const Tea &c)……

Where do I put the Main?

Run.cppMainRun.cppMain

Class CoffeeCoffee()Coffee (const Coffee& c)Coffee& operator =(const Coffee

&c)……

Class TeaTea()Tea (const Tea& c)Tea& operator =(const Tea &c)……

Coffee.o

Run.cppMain

Tea.o

Main.o

Compilation

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

Now can I run my software?

Class CoffeeCoffee()Coffee (const Coffee& c)Coffee& operator =(const Coffee

&c)……

Class TeaTea()Tea (const Tea& c)Tea& operator =(const Tea &c)……

Coffee.o

Run.cppMain

Tea.o

Main.o

Link

g++ -o Debug/CoffeHouse Debug/Coffe.o Debug/Tea.o Debug/run.o

CoffeHouseExecutable

Class CoffeeCoffee()Coffee (const Coffee& c)Coffee& operator =(const Coffee

&c)……MakeCoffe()

Class TeaTea()Tea (const Tea& c)Tea& operator =(const Tea &c)……

…makeCoffe(int sugar);…

Coffee.o

Run.cppMain

Tea.o

Main.o

Link errors

CoffeHouseExecutable

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

Class TeaTea()Tea (const Tea& c)Tea& operator =(const Tea &c)……

External Lib

Espresso.hSomebody else implemented

But where can I find Espresso.h?Run.cpp

Main

Coffee.o

Run.cppMain

Tea.o

Main.o

Compilation

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

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

Class TeaTea()Tea (const Tea& c)Tea& operator =(const Tea &c)……

Espresso.hSomebody else implemented

Coffee.o

Run.cppMain

Tea.o

Main.o

But where is

MakeEsspresso()?

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

Class TeaTea()Tea (const Tea& c)Tea& operator =(const Tea &c)……

Espresso.hSomebody else implemented

Link

CoffeHouseExecutable

Coffee.o

Run.cppMain

Tea.o

Main.o

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

Class TeaTea()Tea (const Tea& c)Tea& operator =(const Tea &c)……

Espresso.hSomebody else implemented

libEspresso.so

Link

CoffeHouseExecutable

Coffee.o

Run.cppMain

Tea.o

Main.o

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

Class TeaTea()Tea (const Tea& c)Tea& operator =(const Tea &c)……

Espresso.hSomebody else implemented

libEspresso.so

Execute

CoffeHouseExecutable

Assignment 2• Assignment goals• The story• Suggested design (one of many)• Specification Questions• POCO and revisit completion in C++• Good habitsGood 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“

class Boy

{

public:

Boy();

Tom tom;

}

// Tom.h

#include “Boy.h“

class Tom

{

public:

Tom();

Boy boy;

}

Avoid including in the headers.// Boy.h

// Forward declarations

class Tom;

class Boy

{

public:

Boy();

Tom* tom;

}

// Tom.h

// Forward declarations

class Boy;

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 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• QuestionsQuestions• 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?Whats now?