|
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.
|
# ? Jul 14, 2020 21:44 |
|
|
# ? Jun 8, 2024 07:03 |
|
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.
|
# ? Jul 14, 2020 21:52 |
|
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 |
# ? Jul 14, 2020 22:35 |
|
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. 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.
|
# ? Jul 14, 2020 22:46 |
|
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.
|
# ? Jul 15, 2020 00:41 |
|
RPATDO_LAMD posted:The fact that the Butt class and ButtType enum have the same name isn't a coincidence. 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.
|
# ? Jul 15, 2020 00:54 |
|
What if it were, and I’m just spitballing here, Butt::Type.
|
# ? Jul 15, 2020 01:12 |
|
Space Gopher posted:If you're working with pure C structs, this makes sense. 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
|
# ? Jul 15, 2020 02:25 |
|
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
|
# ? Jul 15, 2020 02:29 |
|
Space Gopher posted:If you're working with pure C structs, this makes sense. 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."
|
# ? Jul 15, 2020 04:34 |
|
Bruegels Fuckbooks posted:you know how the design patterns books says "favor composition over inheritance"? Inheritance is theft from the public good.
|
# ? Jul 15, 2020 04:35 |
|
fourwood posted:What if it were, and I’m just spitballing here, Butt::Type. yeah that's better
|
# ? Jul 15, 2020 06:54 |
|
fourwood posted:What if it were, and I’m just spitballing here, Butt::Type. Can't forward declare that in C++
|
# ? Jul 15, 2020 07:48 |
|
Bruegels Fuckbooks posted:you know how the design patterns books says "favor composition over inheritance"? are you the guy from the internet that refuses to use inheritance for any problem no matter how wildly appropriate
|
# ? Jul 15, 2020 09:39 |
|
Space Gopher posted:[..] "inheritance" [..] i[..]s a terrible idea. slightly refactored your post
|
# ? Jul 15, 2020 12:38 |
|
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").
|
# ? Jul 15, 2020 13:18 |
|
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.
|
# ? Jul 15, 2020 13:23 |
|
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".
|
# ? Jul 15, 2020 14:09 |
|
Falcorum posted:Can't forward declare that in C++ Sure you can. Just put this somewhere before you need it and you're good to go. C++ code:
|
# ? Jul 15, 2020 14:11 |
|
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
|
# ? Jul 15, 2020 14:13 |
|
Hammerite posted:are you the guy from the internet that refuses to use inheritance for any problem no matter how wildly appropriate
|
# ? Jul 15, 2020 15:10 |
|
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.
|
# ? Jul 15, 2020 15:16 |
|
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. It's like storing values as strings, except they're integers
|
# ? Jul 15, 2020 15:22 |
|
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.
|
# ? Jul 15, 2020 15:39 |
|
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. 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"
|
# ? Jul 15, 2020 16:37 |
|
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.
|
# ? Jul 15, 2020 17:17 |
|
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
|
# ? Jul 16, 2020 00:57 |
|
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.
|
# ? Jul 16, 2020 01:06 |
|
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.
|
# ? Jul 16, 2020 04:43 |
|
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. That's nothing. Old timey calculators had a format for giving angles like 23°42'6.9" that looked something like 23.42069.
|
# ? Jul 16, 2020 05:53 |
|
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. For anyone else reading this, the correct solution is to add a virtual clone method, and avoid copy smfs
|
# ? Jul 16, 2020 06:45 |
|
Xarn posted:For anyone else reading this, the correct solution is to add a virtual clone method, and avoid copy smfs 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.
|
# ? Jul 16, 2020 15:30 |
|
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.
|
# ? Jul 16, 2020 15:50 |
|
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.
|
# ? Jul 16, 2020 16:12 |
|
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?
|
# ? Jul 16, 2020 16:29 |
|
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.
|
# ? Jul 16, 2020 16:31 |
|
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.
|
# ? Jul 16, 2020 16:34 |
|
What?
|
# ? Jul 16, 2020 16:37 |
|
ultrafilter posted:What? 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!
|
# ? Jul 16, 2020 16:39 |
|
|
# ? Jun 8, 2024 07:03 |
|
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).
|
# ? Jul 16, 2020 18:12 |