Don't keep the type(s) of object in the facility if you're dealing with a tongue with a strong typology.
It's usually a design error. You can easily diagnose the Russian translation of the C++-sliding book, which details why you can't do it - except in very rare cases - in short: overhead, extra code, manual checks, a lot of mistakes.For other languages, I think it's easy to find such articles/teachers too.See that the type of object and its meaning are two completely different concepts.Polymorphysics is an inspiration for a programmer not to choose, for example, what function would cause a facility to move?Stone - not movingBird - flyingChicken-- (not birds) walks, but if he's scared, jumping and flying a little, and he's almost always flying if he jumps.Cat, walkingThe car is coming.Mina with traffic detector - explodedIn a language with strong typology and support for polymorphism, you're just causing
Method move and the object itself is doing its own method of moving, and if he doesn't have that method, you might have a mistake in the compilation. No extra checks, no mistakes.P. S.
In addition, there are ways in C++ and Java to know the type of facility:for C++ - RTTI in ranch or SFINAE during the compilation phasefor Java - someObject.getClass()For Java, I assume the challenge getClass can carry additional overhead costs in the ranks, if you start to keep the type of individual value, the costs (pam/tip) will increase further.For C++, the use of RTTI always carries additional costs (and a bunch of problems) and is rarely usedP.P.S.
In the case of meta-programming, in C++, using templates/boxes in the spirit of boosting:hana type/signatures may be slightly blured, but this is another topic for conversation.P.P.P.S.
If you're naming and/or very needed (e.g. if your materials are not some class, but just texture numbers), they need to be kept in constants, accessible language (for c+ this) define/enum/enum classand not strings. Constants will be processed during the compilation phase, remembered less, and you will also receive support for your IDE (as long as she sees the constant MATERIAL_TYPE_CONCRETE (aca concrete, allowed) present in the code, and the lines will be hanging around with all their designers and overheads and without any support from IDEP.P.P.P.S
Not specific to the question, but can help you:
If you're doing a game or something like that that requires a lot of different resources, textur, object models, etc., I would have done the following:Put all the resources in the bd (mysql/postgres/sqlite - on the lookout situation) is allowed in the form of a recording (aidy, name, type of resource, xash object may be) make a simple web-reviser or command crypt to add a resource to the bud.write a simple violin that generates you a headline C++ or Java-class from this database.It's gonna take a day-to-day job, but you're gonna start feeling every time you don't have to your hands add the file to the code, put it in the right catalogue, etc. If for the debag mode you add a record of the frequency of the use of the resource, you can, for example, easily request statistics on what resources you don't use, or for which resources too little texture, etc.