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

  • Home
  • SEARCH
  • 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 612045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:51:02+00:00 2026-05-13T17:51:02+00:00

Been tasked to write some asset tracking software… Want to try to do this

  • 0

Been tasked to write some asset tracking software…
Want to try to do this the right way. So I thought that a lot of assets had common fields.
For instance, a computer has a model and a manufacturer which a mobile phone also has.

I would want to store computers, monitors, mobile phones, etc. So I thought the common stuff can be taken into account using an abstract base class. The other properties that do not relate to one another would be stored in the actual class itself.

For instance,

public abstract class Asset {
private string manufacturer;

    public string Manufacturer { get; set; }
    //more common fields
}

    public class Computer : Asset {
    private string OS;
    public strin OS { get; set; }
    //more fields pertinent to a PC, but inherit those public properties of Asset base
    }

    public class Phone : Asset {
    //etc etc
    }

But I have 2 concerns:

1)If I have a web form asking someone to add an asset I wanted to give them say a radio box selection of the type of asset they were creating. Something to the effect of:

What are you creating

[]computer

[]phone

[]monitor

[OK] [CANCEL]

And they would select one but I dont want to end up with code like this:

pseudocode:

select case(RadioButtonControl.Text)
 {
  case "Computer": Computer c = new Computer(args);
                   break;
  case "Phone": Phone p = new Phone(args);
                break;
  ....
 }

This could get ugly….

Problem 2) I want to store this information in one database table with a TypeID field that way when an Insert into the database is done this value becomes the typeid of the row (distinguishes whether it is a computer, a monitor, a phone, etc). Should this typeid field be declared inside the base abstract class as some sort of enum?

Thanks

  • 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-13T17:51:03+00:00Added an answer on May 13, 2026 at 5:51 pm

    My advice is to avoid this general design altogether. Don’t use inheritance at all. Object orientation works well when different types of objects have different behavior. For asset tracking, none of the objects really has any behavior at all — you’re storing relatively “dumb” data, none of which does (or should) really do anything at all.

    Right now, you seem to be approaching this as an object oriented program with a database as a backing store (so to speak). I’d reverse that: it’s a database with a front-end that is (or at least might be) object oriented.

    Then again, unless you have some really specific and unusual needs in your asset tracking, chances are that you shouldn’t do this at all. There are literally dozens of perfectly reasonable asset tracking packages already on the market. Unless your needs really are pretty unusual, reinventing this particular wheel won’t accomplish much.

    Edit: I don’t intend to advise against using OOP within the application itself at all. Quite the contrary, MVC (for example) works quite well, and I’d almost certainly use it for almost any kind of task like this.

    Where I’d avoid OOP would be in the design of the data being stored. Here, you benefit far more from using something like an SQL-based database via something like OLE DB, ODBC, or JDBC.

    Using a semi-standard component for this will give you things like scalability and incremental backup nearly automatically, and is likely to make future requirements (e.g. integration with other systems) considerably easier, as you’ll have a standardized, well understood layer for access to the data.

    Edit2: As far as when to use (or not use) inheritance, one hint (though I’ll admit it’s no more than that) is to look at behaviors, and whether the hierarchy you’re considering really reflects behaviors that are important to your program. In some cases, the data you work with are relatively “active” in the program — i.e. the behavior of the program itself revolves around the behavior of the data. In such a case, it makes sense (or at least can make sense) to have a relatively tight relationship between the data and the code.

    In other cases, however, the behavior of the code is relatively unaffected by the data. I would posit that asset tracking is such a case. To the asset tracking program, it doesn’t make much (if any) real difference whether the current item is a telephone, or a radio, or a car. There are a few (usually much broader) classes you might want to take into account — at least for quite a few businesses, it matters whether assets are considered “real estate”, “equipment”, “office supplies”, etc. These classifications lead to differences in things like how the asset has to be tracked, taxes that have to be paid on it, and so on.

    At the same time, two items that fall under office supplies (e.g. paper clips and staples) don’t have significantly different behaviors — each has a description, cost, location, etc. Depending on what you’re trying to accomplish, each might have things like a trigger when the quantity falls below a certain level, to let somebody know that it’s time to re-order.

    One way to summarize that might be to think in terms of whether the program can reasonably work with data for which it wasn’t really designed. For asset tracking, there’s virtually no chance that you can (or would want to) create a class for every kind of object somebody might decide to track. You need to plan from the beginning on the fact that it’s going to be used for all kinds of data you didn’t explicitly account for in the original design. Chances are that for the majority of items, you need to design your code to be able to just pass data through, without knowing (or caring) much about most of the content.

    Modeling the data in your code makes sense primarily when/if the program really needs to know about the exact properties of the data, and can’t reasonably function without it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 371k
  • Answers 371k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It's not so precise but works: var scrollPosition = window.pageYOffset;… May 14, 2026 at 6:59 pm
  • Editorial Team
    Editorial Team added an answer I don't know if IE supports application/javascript. Did you try… May 14, 2026 at 6:59 pm
  • Editorial Team
    Editorial Team added an answer When you are doing @user = session[:user] @user variabe is… May 14, 2026 at 6:59 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.