13

First, a Code Review Anti-pattern Please don't do this: record = new String(); This is (barring compiler heroics), creating a brand new empty string literal, when a perfectly good interned string literal is available: record = ""; Using this interned literal "" prevents the creation of a number of identical tiny objects, and will improve the ...


4

Is inheritance really the answer? I think it's been covered that you could dynamically build your product instances, but it's not really clear to me why you'd need to. The object model feels a bit wrong to me. From what I can see you're reading all of the objects in, then storing them in an ArrayList<Product>. There doesn't appear to be a lot of ...


4

Code is generally very clean, although I do have a number of reservations with some of the naming: c prefix for class modules, M for standard ones, is pure noise; Cell as a suffix for something that isn't a cell, is confusing. That kind of thing. I would have named cStyles as Styles, or perhaps StyleProcessor since we don't want to hide Excel.Styles; ...


3

Dog obj1 = new GoldenRetriever(); obj1.Name = "Fluffy"; obj1.IsVaccinated = true; Console.WriteLine(obj1.Name + obj1.IsVaccinated + obj1.Color); Variable names: avoid name s like obj1 why not Dog fluffy=new GoldenRetriever(); You have derived GoldenRetriever and Beagle from Dog. Obviously this is an incomplete example and you may have ...


3

But what do you think, did I use polymorphism in Accounts, CurrentAccount, SavingAccount and also between Person, Customer, Manager classes or not? No, you didn't use polymorphism anywhere in your program. You only work with concrete classes of CurrentAccount, SavingAccount, Customer and Manager. Polymorphism means, that you call the concrete classes ...


3

Ownership This: // NOTE: The Animation object is responsible for the DELETION of the // GraphicsWindow object, the Visualisation object and the DynamicalSystem // object. In effect is behaves like a smart triple pointer! // Animation::~Animation() { delete ptrWindow_; delete ptrVisualisation_; delete ptrSystem_; sets off alarm bells. There ...


3

I think there are two choices with little or no in-betweens: formally specify the products and use a parser keep the current behavior, which means determining the product and switching. so in the end, you have to either take a big step and create a formal description and a parser (parser generation is a university course, mind you). Or you'll have to ...


3

Remarks for beginners: Never hide a pointer behind a typedef! Never! It makes the code confusing and very hard to read and maintain. You can't unfortunately use a generic Node pointer like in your code, because this isn't well-defined by the language. There are ways around it, but they are a bit controversial (see advanced reply below). Generally, when ...


2

This would be long comment. These general exercises are meant for giving a clearer visual to the code design and syntax in simple terms. It would be hard to criticize, and you will get very different feedback perspectives, where some of them would conflict each other and confuses you. It would give you a small percentage improvements, but not the ...


2

Is this common practice? Enum-based type tracking in C? Yes. Would there be a better way to do it? Depends on a few things, including your definition of better. I think this is fine, but if your type-conditional code ends up being extremely long, then you can move to a more C++-style approach, where instead of tracking a type enum, you track function ...


2

funtools.singledispatch() Take a look at the code for functools.singledispatch(). It's different in that it dispatches based on the type of the first argument. Look at how it wraps the first function with an object, so a separate controller object isn't needed. It also has code to deal with method resolution order if the overloaded functions are at ...


1

Over all the code is really good but LoadToTable() could be tweaked. Public Sub LoadToTable() 1 Dim stylesTable As ListObject 2 Dim currentStyle As Style 3 Dim tempStyleInfo() As Variant 4 Dim counter As Long 5 Dim counterStyles As Long 6 counter = 0 7 counterStyles = ThisWorkbook.Styles.Count 8 ReDim tempStyleInfo(...


1

I tackled the book a time ago, skipped this chapter and came back now since this topic is highly/excessive used in the Qt Toolkit - even tho its a while ago. Anyhow, you asked for: I'm especially concerned about my use of dynamic_cast, as that isn't covered yet and I suspect there's a better way. Yes, by declaring the compare in the Comparable class itself,...


Only top voted, non community-wiki answers of a minimum length are eligible