Westicle
Westicle

Reputation: 87

When should I move from using base data types to properties?

Trying to get my head around the best way to build my applications.

Current app is based around an Opportunity; a log of potential work with fairly typical properties like Project Manager, Fee, Start Date blah blah blah.

One of the properties is Stage which up until now I have kept as a string (Won, Lost, No-Go etc.). I'm getting the urge to convert it to a class of its own although for now it will only have one property: Name, which is a string. I'm pretty sure at some point in the future the Stage object will have other properties though.

Is it crazy/overkill to create a class for the Stage property now?

Upvotes: 1

Views: 57

Answers (3)

Meta-Knight
Meta-Knight

Reputation: 17875

There is a concept called YAGNI (You Aren't Gonna Need It) that says: Don't look too far into the future. Unless a Stage class is useful right now, just use a string property.

If you find out that you need a Stage class at some point in the future, adding it in later shouldn't be much more effort than it is now. And if you find out that you DON'T need it, than you just saved some time, and reduced the complexity of your design.

Some reading about this YAGNI principle:

Upvotes: 0

Matt Wilko
Matt Wilko

Reputation: 27342

It is much easier to add additional properties to an existing Class than to convert a Property to a Class in the future so if you think you may need to convert it I would say just do it.

Upvotes: 1

Ademar
Ademar

Reputation: 5747

Depends of what you see in the future for this class. If you see that it will be extend then why not? but you can always have a string and then when necessary create a class and replace it. hope it helps

Upvotes: 0

Related Questions