So I have this task of mapping two hotel catalogs; both are csv files. I created two classes, based on their responsibilities : 1. CatalogManager : handles the I/O operations for catalogs. 2. CatalogMapper : Handles the mapping task of two catalogs.
The definitions are as follows :
public static class CatalogManager
{
public static List<Hotel> GetHotels(string filePath) { }
public static void SaveHotels (List<Hotel> hotels, string filePath) { }
public static void SaveMappedHotels (List<MappedHotel> hotels, string filePath) { }
public static List<string> GetHotelChains(string filePath) { }
}
public static class CatalogMapper
{
public static List<MappedHotel> MapCatalogs (List<Hotel> masterCatalog, List<Hotel> targetCatalog) { }
public static FetchAddressGeoCodes (Hotel.Address address)
{ // fetch address's geocode using Google Maps API }
public static string GetRelevantHotelChain (string hotelName)
{
List<string> chains = CatalogManager.GetChains();
// find and return the chain corresponding to hotelName.
}
}
A typical mapping operation may go something like :
List<Hotel> masterCatalog = CatalogManager.GetHotels(masterFilePath);
List<Hotel> targetCatalog = CatalogManager.GetHotels(targetFilePath);
List<MappedHotel> mappedHotels = CatalogMapper.MapHotels(masterCatalog, targetCatalog);
CatalogManager.SaveMappedHotels(mappedHotels, mappedCatalogFilePath);
As the code shows, both the classes are static. Though I found them right and working, I still feel there is something wrong with this design in terms of OOP. Is it fine that both of the classes are simply static? I found no need of instantiating them. Also, what are other flaws in this design? I am sure flaws are present. What are the solutions for those?