Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4115586
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:36:04+00:00 2026-05-20T22:36:04+00:00

Assume I have some program that pulls airline data. Each airline data uses a

  • 0

Assume I have some program that pulls airline data. Each airline data uses a different system in which I need to pull the data (xml) from. Because of the difference in each system, basically the xml being different and maybe some propeterties, I decide to implement an interface to implement for each airline system. What I find though is that each airline, although different in many aspects, also contains many similarities, so if I do it the interface way first, I might have to do something like this:

public interface IAirlineSystem {
    public void PullData();
}

Now for each airline system (I am making these names up), I might do something like:

public class Oberon : IAirlineSystem {
    string Name {get;set;}
    int Code {get;set;}
    public void Initialize()
    {
        //initialize code here
    }
    public void PullData()
    {
       //code here
    }
}

The above is just one airline system, but imagine I have more (like +10), another one might be:

public class AirSys: IAirlineSystem {
    string Name {get;set;}
    int Code {get;set;}
    public void Initialize()
    {
        //initialize code here
    }
    public void PullData()
    {
       //code here
    }
}

In the code above:

The name and code properties are unique to each Airline system. Initialize contains the exact same code for each implementation and PullData is unique to each system. Because of duplicates in the classes, is this where I could use an abstract class to hold the code of the Initialize method. I have heard that it is good practice to actually mix interfaces and abstract classes, what would be an example of this using my airline system example?

Another thing that comes up is that lets assume that I have another method in the interface called ValidateData, but not all airline systems need to call it, but if I put it in an interface, I would need to implement an empty method if it is not needed. Is there a way I can prevent from having to do this. Is this another reason for using an abstract class, maybe with a virtual method, so it can be overridden as needed. If I made ValidateData an abstract method, it would still need to be implemented, right?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T22:36:05+00:00Added an answer on May 20, 2026 at 10:36 pm

    Your explanation seems to point towards using an abstract class. You could have an abstract class that would have an implementation of the Initialize method, and you would not need to repeat it in the Oberon and AirSys subclasses. PullData could be an abstract method that would then get implemented in the separate subclasses. And yes, only the class that requires the ValidateData method would have it implemented.

    Example would be:

    public abstract class AirlineSystemBase
    {
        string Name { get; set; }
        int Code { get; set; }
    
        public void Initialize()
        {
            //code goes here
        }
    
        public abstract void PullData();
    
    }
    
    public class Oberon : AirlineSystemBase
    {
        public override void PullData()
        {
            //code goes here
        }
    }
    
    public class AirSys : AirlineSystemBase
    {
        /// <summary>
        ///     that is if say only AirSys class had a need for this ValidateData() method
        /// </summary>
        public void ValidateData()
        {
            //code goes here
        }
    
        public override void PullData()
        {
            //code goes here
        }
    
    }
    

    OR if you want to use both interface and abstract class:

    public interface IAirlineSystem
    {
        void PullData();
        void ValidateData();
    }
    
    public abstract class AirlineSystemBase : IAirlineSystem
    {
        string Name { get; set; }
        int Code { get; set; }
    
        public void Initialize()
        {
            //code goes here
        }
    
        public abstract void PullData();
    
        public virtual void ValidateData() 
        { 
            //code goes here
        }
    
    }
    
    public class Oberon : AirlineSystemBase
    {
        public override void PullData()
        {
            //code goes here
        }
    }
    
    public class AirSys : AirlineSystemBase
    {
        /// <summary>
        ///     that is if say only AirSys class had a need for this ValidateData() method
        /// </summary>
        public override void ValidateData()
        {
            //code goes here
        }
    
        public override void PullData()
        {
            //code goes here
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some surface data that is generated by an external program as XYZ
Assume you have some objects which have several fields they can be compared by:
I have some code that effectively does this : File file = new File(C:\\Program
Assume that i have written a program in C++ without using RTTI and run-time
Assume we have a trivial Java program that consists of just one class: public
Assume I have an ASP.NET MVC app that's not doing anything too fancy (no
I have a bunch of items in my program that all belong to a
I have some HUGE log files (50Mb; ~500K lines) I need to start filtering
i have a program that needs command line arguments in the form : ./my_program
I have some commercial equipment that I can connect to with a .Net library

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.