1

Before any down voting or blaming, please bear in mind that this is my first "serious" Python project. Before this I have only coded a program that uses several Google API's to do stuff, and not much more besides lots of various code testing and exercises, but I haven't get much in to classes yet.

Now, I am coding an application for the hotel industry that calls an API and retrieves data on Json format. Right now I have the data sets controlled and I have been able to retrieve useful information and make operations with it. The data returned is the business sites ( The name of the different hotels ), the different departments on the hotels the generate revenue ( The bar, the restaurant, the rooms themselves, etc. ) And finally also the data gets grouped depending of the type of income ( it can be Food, Beverage, Extra services, etc. )

But I see a lot of potential on this project to get bigger and make it do much more than those initial, basic operations. In order to try to make it scalable, and to be able to code faster, I have thought of using classes to divide the different categories as objects so to later I can use them freely on the code and do a bunch of different operations with it.

So I thought of dividing those items in to classes and to create a hierarchy :

class IncomeSources(object):

class BusynessSite(IncomeSources):
      def hotel1:

      def hotel2:

class TypeofIncome(IncomeSources,BusynessSite):
      def beverage:
      def food:
      def transportation:

Those classes would hold methods that basically contain the tags for each source so to extract the data and do operations with it. Will this be a good approach ? Will I take advantage of inheritance by organizing the code this way ? Is this even right ? Thank you.

1 Answer 1

0

It seems to me that you described 4 concepts:

  • BusinessSite, which has a name and list of departments
  • Department, which has a name and dictionary of (TypeOfIncome,Income)
  • TypeOfIncome, which is probably just a string
  • Income, which is probably just a number

None of these concepts require inheritance, but it could make sense to create classes for BusinessSite and Department. But the best design also depends on what operations you want to perform on the data.

1
  • Hi, thank you for answering ! I want to make accountable operations and then build dataframes with the results.
    – xavier
    Mar 8, 2016 at 20:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.