Ninjakreborn Posted September 24, 2010 Share Posted September 24, 2010 This is an open questions. I have always reused my code. I go into a past project and strip out some code and re-use it all the time. In what ways do you guys re-use your code? Do you just take it out of projects you had built. I know sometimes I form them into functions if I re-use them a lot. However, after getting up there in projects and have a graveyard of projects you have done, what do you do to keep track of all the code you have written to use as reference? Quote Link to comment https://forums.phpfreaks.com/topic/214286-re-using-code/ Share on other sites More sharing options...
seventheyejosh Posted September 24, 2010 Share Posted September 24, 2010 I use OOP, so I have written lots of classes. If I need to use one, just add it to the application. If it isn't large enough to yield a worthwhile class, but is still useful, I have a snippet library, nice and sorted. I try to avoid having to go back and rip out a few lines of code, as that isn't really re-useability. Sometimes it's unavoidable though. - Josh Quote Link to comment https://forums.phpfreaks.com/topic/214286-re-using-code/#findComment-1115126 Share on other sites More sharing options...
ignace Posted September 24, 2010 Share Posted September 24, 2010 I go into a past project and strip out some code and re-use it all the time. That isn't re-using, not as I see it. I don't have to strip out some code in the Zend framework to use it in a new project do I? Re-think your design quite possibly your missing something to truly make your class re-usable. In what ways do you guys re-use your code? Do you just take it out of projects you had built. ... what do you do to keep track of all the code you have written to use as reference? All projects are under version-control and have a svn:externals defined for both Zend framework and our own framework that has grown over the years. When we get a new project we create a domain design often this design leads to new components (eg Services) that are not domain-related and thus suitable for the Infrastructure layer (frameworks, libraries, and the like). It sometimes happens that we adopt domain classes (eg Models) to new projects but these - like the project - evolve over time. We never re-use classes from the Application layer (eg Controllers) as the number of lines in those classes are negligible or too application-specific to be re-usable. Quote Link to comment https://forums.phpfreaks.com/topic/214286-re-using-code/#findComment-1115157 Share on other sites More sharing options...
.josh Posted September 24, 2010 Share Posted September 24, 2010 reusable code is the core principle behind functions and, well, virtually all of object oriented programming. Quote Link to comment https://forums.phpfreaks.com/topic/214286-re-using-code/#findComment-1115312 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.