I’m wondering about the performance differences between imports and inherits in a .net app.
I currently program by creating multiple classes that logically define my objects. e.g. a class for customers, users and product.
When i want to use these classes in a page i have to import them eg. “Imports Custmomers” and then later in my code i have to create a variable and datatype it before i can use the sub routines and functions from class.
I understand from a coding perspective this keeps it all neat and tidy.
So my question Would it be not better to combine all my classes into a base class, inherit that base class, rather than import it, when i want to use it and so cut down on the extra declarations and associated code that come from importing a class; and if i did this would it aid performance?
No, it will not improve performance to use a base class instead of separate classes, it will just make the application harder to maintain and extend. Prefer composition over inheritance.
If you’re having performance problems with your application use a profiler and check where the hotspots are.
“Importing” a class is just a way to tell the compiler that you are too lazy to type the fully qualified names of the types all over your code and has no impact on the runtime performance.