I'm working on a website that was coded in ColdFusion. I have a CSS/HTML template I would like to apply to the content of every page, without duplicating any more code than necessary. I've gotten kind of spoiled by ASP.NET's master pages, which would be my preferred way to implement this site. Unfortunately, that option is unavailable to...
I've got an ASP.NET application that shows grades for different kinds of students. Some students have a self-paced course that doesn't include late penalties and quizzes, and others have a standard classroom course that does.
So, when displaying a student's grade, I determine which category that student falls in, and then render the gra...
In most cases, it seems that instead of writing their own code, programmers copy code from any available website and use them in their application.
Is it good for a developer?
I believe this habit dumps the developers.
Is it wise to follow this habit?
...
The reason for this, I find myself being asked to make
replacement classes for boost's classes in a commercial project.
And I am asked to test them against the boost class's behaviour.
This makes absolutely no sense to me. I seldom see a license as
open as boost's.
Maybe there will be added functionality in the future, but since
boost'...
My company has two or three web apps that use a lot of common code -- a custom MVC framework, utility classes, JavaScript libraries, and so on.
We'd prefer not to duplicate all this code in each app, because we end up with several slightly different versions of it in use. But we don't want the apps to require the same exact copy of this...
I maintain a good number of vbscripts for performing various startup scripts on my network and have a handful of functions that I use in almost all of them.
Short of copy and paste, does anyone have suggestions for how I can go about creating libraries of reusable vbscript code. I'm not averse to using a code generator for doing so as ...
I'm working on a CRUD site with a lot of very similar forms for adding new data. In other words:
AddMovie.aspx, AddGame.aspx, AddBeer.aspx, AddAdd.aspx
I keep thinking to myself, "Self, it would be really nice to have a single Add.aspx instead of re-writing so many similar pages - plus all those OOP nerds would think I'm cool since I'm...
OK I have a few classes I have made or found on the web that I plan to use in multiple projects, I would rather store these classes in a central location instead of copy+pasting them into each project.
my Flex projects have their own workspaces inside the path Flex/WorkSpaces/< workSpaceName >
If I wanted to put another folder inside t...
UPDATE:
So pretty much everyone here told me that i just need to start over again on how i designed my classes (thank you folks for your excellent answers by the way!). Taking the hint, i started doing extensive reading on the strategy pattern. I want to create behavior classes (or strategy classes) that inherit from an abstract base c...
Is there a way to use the value from the CASE WHEN test as one of its results without writing out the select statement twice (since it could be long and messy)? For example:
SELECT id,
CASE WHEN (
(SELECT MAX(value) FROM my_table WHERE other_value = 1) IS NOT NULL
)
THEN (
SELECT (MAX(value) FROM my_ta...
There is basic persistence of Javascript vars/etc. You call a function/method, and the next time you call that same function/method, it is holding the data from the last time.
You can delete the vars when you are done with them, but that removes the advantage of using the code again for that instance.
So what is the proper way to write...
I'd like to adhere to the Don't-Repeat-Yourself principle, but sometimes when I write PHP together with HTML and CSS, if I re-use the same code for different situations, my code soon will have so many if-then-else that the code is not easily maintainable.
This may be a bigger issue if Smarty, the templating engine is used, because most ...
I recently completed a project for a custom report UI in Flex. Now, I've been tasked with creating a new application that is essentially a "lite" version of the original UI. It will include only a few of the options that are in the original application. Also, it needs to be a separate application.
I do not want to duplicate my code, so ...
I'd like to avoid coding my own version of IFactory, ILog, IRepository and other common interfaces & implementations in my projects but find that commonly used libraries containing these tend to be focused on a particular concrete subsystem (one ORM, one IoC container, one logger). I've come across a some that seem more abstract (NCommon...
What's best practice for reuse of code versus copy/paste?
The problem with reuse can be that changing the reused code will affect many other pieces of functionality.
This is good & bad : good if the change is a bugfix or useful enhancement. Bad if other reusing code unexpectedly becomes broken because it relied on the old version (or t...
I got myself in a situation where using the System.Attribute class seemed (at first glance) to be a good idea.
I have an object to be printed in my application, and I need a label before each property (or just a string before it). I could put each property hardcoded like:
Console.WriteLine("Color:"+obj.color);
Console.WriteLine("Size:...
A few years ago, we needed a C++ IPC library for making function calls over TCP. We chose one and used it in our application. After a while, it became clear it didn't provide all functionality we needed. In the next version of our software, we threw the third party IPC library out and replaced it by one we wrote ourselves. From then on, ...
I am writing a number of small, simple applications which share a common structure and need to do some of the same things in the same ways (e.g. logging, database connection setup, environment setup) and I'm looking for some advice in structuring the reusable components. The code is written in a strongly and statically typed language (e....
There are various snippets on the web that would give you a function to return human readable size from bytes size:
>>> human_readable(2048)
'2 bytes'
>>>
But is there a Python library that provides this?
...
In the near future, I will be inheriting a somewhat large project. I've been making some small updates to it recently, and noticed that parts of it could use some refactoring, since there are methods that perform the same operation with a small difference.
I was wondering if there is a tool that will take a bunch of source code and f...