OO design of ad application [closed]

  softwareengineering

I am making an OO design for an app. So far I’ve come with this, I looks like it could work, but I am not sure of correctness of its design.

Old design
enter image description here

EDIT

Okay so, I used factory pattern, and it looks good to me. Is this good design ?
enter image description here

You are building application that will load data from several
different advertising systems and then store the data into database,
so it will be possible to analyze them.

You need to take in mind that every advertising system has different
structure of report: Different named columns, different order of
columns, different date formats. Also data from ad systems are in
different data formats(JSON,CSV,XML),

Reports from each system contains different amount of columns, our
application is interested only in some of them: date, ad_campaing,
ad_group, keyword, impressions, price (in every system they have
different name)

5

Your report data layer is not Open-Closed (https://en.m.wikipedia.org/wiki/Open/closed_principle), it knows all formats and must be changed in order to be extended with new formats.

The design didn’t explain how the reports are constructed, which is the heart of this system. This is something you may wish to address at this stage.

1

I would go with

Advert
{
    string id;
    var ad_group;
    var keyword;
    var impressions;
    var price ;
}

AdRepository_MyDatabase
{
    InsertAdvert(Advert advert);
    GetAdverts();
}

//this class is the only thing that knows about the bing format and how to
//get the bing adverts and convert them to our adverts
AdRepository_Bing
{
    List<Advert> GetAdverts();
}

AdRepository_Google
{
    List<Advert> GetAdverts();
}

etc

WorkerService
{
    DownloadAdverts()
    {
         foreach(repo in RepositoryCollection)
         {
              var ads = repo.GetAdverts();
              foreach(ad in ads)
              {
                     mydatabaseRepo.InsertAdvert(ad);
              }
         }
    }
}

2

I do believe it is a good architecture, but I came with a question, how would you say to the AdvertisingFactory how to convert the string to a report, I hope I understood the question right. So it came to me an implementation of an Strategy Pattern:

Strategy Pattern

There the one that does your conversion is the ReportMapper, because I didn’t found another name, and the factory wraps it all.

3

LEAVE A COMMENT