So what does code-reuse mean in terms of Object Oriented Programming? Well, it doesn’t refer to copying and pasting code from one application to another, but rather to the creation of components that can be re-used through class instantiation. In other words lets say you create some code that performs a specific task, and within another application the need exists to re-use that functionality, you would instantiate a class and invoke the functionality within the class that you want to re-use it. Make sense?
I have also pondered about namespaces, and my theory is that if you use namespaces wisely you only have to declare a namespace in one class and let other classes inherit from the class that uses that namespace. Thus lets say you connect to a SQL Server 2005 database, and you intend to use the System.Data.SqlClient namespace, you could use that namespace once in a class and let any other classes inherit from the class that contains the System.Data.SqlClient namespace. Thus you only use the namespace once. Thats my thinking anyway.
Place your comment