Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

SAVE-LISP-AND-DIE posted:

Pffft, call me when every "Helper" class (which is every class that's not directly tied to a UI) has been separated into an interface and implementation class, but each class has the prefix "EF" (Entity Framework) whether it uses EF or not. EFBarHelper, EFFooHelper, EFBazHelper.

See, this is really weird to me because I often create classes with names like "ThingHelper" but they're pretty much always static classes containing, well, helper methods that are used by other things. If it's got enough of an identity that you need it to hang around as an object then it should have enough of an identity to suggest a better name.

Adbot
ADBOT LOVES YOU

Vanadium
Jan 8, 2005

imo, if you can't call your thing Foo because there's already a Foo, you should just call it Foo_ and own the fact that there is a name collision instead of trying to obfuscate it by coming up with new taxonomies for different roles of classes or w/e.

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆

Vanadium posted:

imo, if you can't call your thing Foo because there's already a Foo, you should just call it Foo_ and own the fact that there is a name collision instead of trying to obfuscate it by coming up with new taxonomies for different roles of classes or w/e.

The fact that the Butt class and ButtType enum have the same name isn't a coincidence.
ButtType is deeply tied to Butts. Each instance of a Butt will have one of several ButtTypes, which other code will look at to change its behavior (like the display code choosing a different description string for the Butt).

RPATDO_LAMD fucked around with this message at 22:37 on Jul 14, 2020

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

Vanadium posted:

imo, if you can't call your thing Foo because there's already a Foo, you should just call it Foo_ and own the fact that there is a name collision instead of trying to obfuscate it by coming up with new taxonomies for different roles of classes or w/e.

If you find this happening a lot, it probably means that your names are insufficiently descriptive, not that your language lacks enough words to describe all the aspects of the domain.

Naming is hard, but I don't think the answer is to throw your hands in the air and say gently caress it.

RPATDO_LAMD posted:

The fact that the Butt class and ButtType enum have the same name isn't a coincidence.
ButtType is deeply tied to Butts. Each instance of a Butt will have one of several ButtTypes, which other code will look at to change its behavior (like the display code choosing a different description string for the Butt).

ButtTypes, ButtEvents, and ButtPlugins are butt-related but not Butts. If you need to make a ButtClass because Butts already exist, maybe one of them is actually a Taint.

Xik
Mar 10, 2011

Dinosaur Gum
It doesn't matter what you call poo poo as long as it's consistent.

Not a single gently caress is given if you chose helper or until but if there are both in the same project that's a horror in my book.

Space Gopher
Jul 31, 2006

BLITHERING IDIOT AND HARDCORE DURIAN APOLOGIST. LET ME TELL YOU WHY THIS SHIT DON'T STINK EVEN THOUGH WE ALL KNOW IT DOES BECAUSE I'M SUPER CULTURED.

RPATDO_LAMD posted:

The fact that the Butt class and ButtType enum have the same name isn't a coincidence.
ButtType is deeply tied to Butts. Each instance of a Butt will have one of several ButtTypes, which other code will look at to change its behavior (like the display code choosing a different description string for the Butt).

If you're working with pure C structs, this makes sense.

If you're using a type system that includes post-1970s concepts like "inheritance" and "polymorphism" it's a terrible idea.

fourwood
Sep 9, 2001

Damn I'll bring them to their knees.
What if it were, and I’m just spitballing here, Butt::Type.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

Space Gopher posted:

If you're working with pure C structs, this makes sense.

If you're using a type system that includes post-1970s concepts like "inheritance" and "polymorphism" it's a terrible idea.

are you the guy from the examples in an intro to oop textbook that uses inheritance for every single problem no matter how wildly inappropriate

redleader
Aug 18, 2005

Engage according to operational parameters

Space Gopher posted:

But, if you're not interfacing with a crappy or missing type system (say, because you're deserializing something off the wire) then why not just use the tool you've already got?

because i don't have time to go back and fix it all

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Space Gopher posted:

If you're working with pure C structs, this makes sense.

If you're using a type system that includes post-1970s concepts like "inheritance" and "polymorphism" it's a terrible idea.

you know how the design patterns books says "favor composition over inheritance"?

it really should be worded "gently caress inheritance, and gently caress you for thinking about using inheritance. also gently caress plato too while we're at it."

Absurd Alhazred
Mar 27, 2010

by Athanatos

Bruegels Fuckbooks posted:

you know how the design patterns books says "favor composition over inheritance"?

it really should be worded "gently caress inheritance, and gently caress you for thinking about using inheritance. also gently caress plato too while we're at it."

Inheritance is theft from the public good. :ussr:

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆

fourwood posted:

What if it were, and I’m just spitballing here, Butt::Type.

yeah that's better

Falcorum
Oct 21, 2010

fourwood posted:

What if it were, and I’m just spitballing here, Butt::Type.

Can't forward declare that in C++ :v:

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Bruegels Fuckbooks posted:

you know how the design patterns books says "favor composition over inheritance"?

it really should be worded "gently caress inheritance, and gently caress you for thinking about using inheritance. also gently caress plato too while we're at it."

are you the guy from the internet that refuses to use inheritance for any problem no matter how wildly appropriate

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

Space Gopher posted:

[..] "inheritance" [..] i[..]s a terrible idea.

slightly refactored your post

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
Dealing with a legacy database where they've represented quantities that are properly regarded as sequences of integers as single integers so that when the integer is expressed in base-10 it reads like the represented quantity.

for example, a UTC offset of "four hours and thirty minutes" is represented as the integer 430, or a coordinate of "ten degrees, twenty minutes and thirty seconds" is represented as the integer 102,030.

I have no idea what to refer to this scheme as in methods I am writing to decode it (other than "stupid").

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
Binary-coded decimal has a similar structure - each binary chunk represents a decimal value, with the higher binary values unused. i.e. 0x09 (which means decimal 9) is immediately followed by 0x10 (which means decimal 10), and 0x0A-0x0F are unused.

It sounds like the scheme you've got is decimal-coded stupidity. I suppose you could call it a decimal coding if you wanted to avoid offending the original authors.

Xerophyte
Mar 17, 2008

This space intentionally left blank

Hammerite posted:

I have no idea what to refer to this scheme as in methods I am writing to decode it (other than "stupid").

I suggest "stringteger".

Absurd Alhazred
Mar 27, 2010

by Athanatos

Falcorum posted:

Can't forward declare that in C++ :v:

Sure you can. Just put this somewhere before you need it and you're good to go.
C++ code:
namespace Butt
{
	class Type;
}

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Xerophyte posted:

I suggest "stringteger".

I ended up calling it a "decimal-coded aggregated integer", because I have a reputation for verbosity to uphold both here and elsewhere

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Hammerite posted:

are you the guy from the internet that refuses to use inheritance for any problem no matter how wildly appropriate
i was skeptical of that guy. i'm working on a product now where the original devs overused the technique to the point where some classes have an inheritance chain of like 8 deep and now I subscribe to that dude's newsletter.

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


If you have a shallow but broad class tree, inheritance is fine. If it's deep, or if you're using multiple inheritance in a non-trivial way, you're going to have a bad time. Ask me about the day I wrote 60 copy constructors to deal with an object slicing problem.

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

Hammerite posted:

Dealing with a legacy database where they've represented quantities that are properly regarded as sequences of integers as single integers so that when the integer is expressed in base-10 it reads like the represented quantity.

for example, a UTC offset of "four hours and thirty minutes" is represented as the integer 430, or a coordinate of "ten degrees, twenty minutes and thirty seconds" is represented as the integer 102,030.

I have no idea what to refer to this scheme as in methods I am writing to decode it (other than "stupid").

It's like storing values as strings, except they're integers

1337JiveTurkey
Feb 17, 2005

Packed decimal format as opposed to packed binary format or whatever. If technical limitations mean that you need to fit several logical fields into one word or something it can sort of make sense.

more falafel please
Feb 26, 2005

forums poster

Hammerite posted:

Dealing with a legacy database where they've represented quantities that are properly regarded as sequences of integers as single integers so that when the integer is expressed in base-10 it reads like the represented quantity.

for example, a UTC offset of "four hours and thirty minutes" is represented as the integer 430, or a coordinate of "ten degrees, twenty minutes and thirty seconds" is represented as the integer 102,030.

I have no idea what to refer to this scheme as in methods I am writing to decode it (other than "stupid").

is there any way to tell if a value has a zero as its least-significant part or if it's just not expressed? like, could 430 be "0 hours, 4 minutes, 30 seconds"

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

more falafel please posted:

is there any way to tell if a value has a zero as its least-significant part or if it's just not expressed? like, could 430 be "0 hours, 4 minutes, 30 seconds"

amazingly enough, they do manage to be consistent about what the smallest unit is. so in the case of time offsets it is always hours and minutes, never any seconds and never just hours.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

ultrafilter posted:

If you have a shallow but broad class tree, inheritance is fine. If it's deep, or if you're using multiple inheritance in a non-trivial way, you're going to have a bad time. Ask me about the day I wrote 60 copy constructors to deal with an object slicing problem.

What about the day where you wrote 60 copy constructors to deal with an object slicing problem

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


Suspicious Dish posted:

What about the day where you wrote 60 copy constructors to deal with an object slicing problem

I had to write 60 copy constructors to deal with an object slicing problem. The class diagram was about six levels deep and involved multiple inheritance in a non-trivial way. It took me all day and I was very unhappy by the end.

This was back around 2005 or so, so I don't remember a lot of details, but it was meant to be a cross-platform UI library for desktop applications. So you had one layer of hierarchy for various types of form controls and their specializations, and then another for the Windows implementation of those controls. Various parts of the library would maintain an array of pointers to either top-level type, and when you copied them using the compiler-provided copy constructors, it only got the top-level type's fields. Somebody had to fix that, and I drew the short straw.

KaneTW
Dec 2, 2011

I avoid inheritance like the plague when I can. If I need some of its features, there's often better ways to do it in most languages.

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Hammerite posted:

Dealing with a legacy database where they've represented quantities that are properly regarded as sequences of integers as single integers so that when the integer is expressed in base-10 it reads like the represented quantity.

for example, a UTC offset of "four hours and thirty minutes" is represented as the integer 430, or a coordinate of "ten degrees, twenty minutes and thirty seconds" is represented as the integer 102,030.

I have no idea what to refer to this scheme as in methods I am writing to decode it (other than "stupid").

That's nothing. Old timey calculators had a format for giving angles like 23°42'6.9" that looked something like 23.42069.

Xarn
Jun 26, 2015

ultrafilter posted:

I had to write 60 copy constructors to deal with an object slicing problem. The class diagram was about six levels deep and involved multiple inheritance in a non-trivial way. It took me all day and I was very unhappy by the end.

This was back around 2005 or so, so I don't remember a lot of details, but it was meant to be a cross-platform UI library for desktop applications. So you had one layer of hierarchy for various types of form controls and their specializations, and then another for the Windows implementation of those controls. Various parts of the library would maintain an array of pointers to either top-level type, and when you copied them using the compiler-provided copy constructors, it only got the top-level type's fields. Somebody had to fix that, and I drew the short straw.

For anyone else reading this, the correct solution is to add a virtual clone method, and avoid copy smfs :v:

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


Xarn posted:

For anyone else reading this, the correct solution is to add a virtual clone method, and avoid copy smfs :v:

In C++ this won't work. A derives from B, B derives from C. If C has a pure virtual method clone() and B implements it, A will use B's implementation. There's no way to require that every class in an inheritance hierarchy have its own implementation of clone(). I'm not aware of any language that does have this feature.

Absurd Alhazred
Mar 27, 2010

by Athanatos

ultrafilter posted:

In C++ this won't work. A derives from B, B derives from C. If C has a pure virtual method clone() and B implements it, A will use B's implementation. There's no way to require that every class in an inheritance hierarchy have its own implementation of clone(). I'm not aware of any language that does have this feature.

It's not a matter of having a language tool to require it (aside from = 0, which will at least force all direct inheritors of the base class to implement it), it's that if you make it clone-based, your copy-enabling work becomes linear instead of quadratic in the number of classes overall.

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


Absurd Alhazred posted:

It's not a matter of having a language tool to require it (aside from = 0, which will at least force all direct inheritors of the base class to implement it), it's that if you make it clone-based, your copy-enabling work becomes linear instead of quadratic in the number of classes overall.

I have no idea what you're on about here, but it's a UI engine. It generates text for users to read and buttons for them to click on. The cost of copies in terms of the number of classes in the hierarchy doesn't matter.

Absurd Alhazred
Mar 27, 2010

by Athanatos

ultrafilter posted:

I have no idea what you're on about here, but it's a UI engine. It generates text for users to read and buttons for them to click on. The cost of copies in terms of the number of classes in the hierarchy doesn't matter.

How many classes were there in that hierarchy? Were there 60 of them?

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


Absurd Alhazred posted:

How many classes were there in that hierarchy? Were there 60 of them?

Yes, but there was no class with more than 5 or 6 levels between it and the parent. Also--and I cannot stress this enough--the program is UI-bound.

Absurd Alhazred
Mar 27, 2010

by Athanatos

ultrafilter posted:

Yes, but there was no class with more than 5 or 6 levels between it and the parent. Also--and I cannot stress this enough--the program is UI-bound.

Oh, so it wouldn't have helped. I'm not talking about run performance, I'm talking about work, for the program, to add/maintain things.

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


What?

Absurd Alhazred
Mar 27, 2010

by Athanatos

I thought that when you said "copy constructor" you meant you had to deal with every combination of X = Y where X and Y were part of that hierarchy, which would be quadratic in the number of classes. But it's not, so never mind!

Adbot
ADBOT LOVES YOU

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
More adventures in the database designed by lunatics. Table T represents a particular facet of entities tracked by the database. It has a column C which stores either the type of row (essentially an enum), or the identity of another row in table T (the "referenced row"). Referenced rows may not be chained. If column C contains a reference to another row, then the type of row is indicated by the value of C in the referenced row. Other columns in T are quantities which are either absolute, or if the row references another row, relative to that row (so you have to add them to the corresponding values in the other row to get the true values). But actually, if the entity in question has certain combinations of attributes, then the quantities stored by T are already absolute, and don't need any such processing. The information that allows you to determine whether the values are relative or absolute is partly found in another table, and partly not present in the database (it has to be read from a file that forms part of the input to the program I am replacing).

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply