views:

156

answers:

6

We are in a situation whereby we have 4 developers with a bit of free time on our hands (talking about 3-4 weeks).

Across our code base, for different projects, there are a number of framework-y type of code that is re-written for every new project that we start. Since we have some free time on our hands, I'm in the process of creating a "standard" set of libraries that all projects can re-use, such as:

  1. Caching
  2. Logging

Although these 2 above would rely on libraries such as Enterprise Library, each new project would write its own wrappers around it, etc, so we're consolidating all these code.

I'm looking for suggestions on the standard libraries that you built in-house that is shared across many projects.

To give you some context, we build LOB internal apps and public facing websites - i.e. we are not a software house selling shrink-wrap, so we don't need stuff like a licensing module.

Any thoughts would be much appreciated - our developers are yearning to write some code, and I would very much love to give them something to do that would benefit the organization in the long run.

Cheers

+6  A: 
  • Unit Testing Infrastructure - can you easily run all your unit tests? do you have unit tests?
  • Build Process - can you build/deploy an app from scratch, with only 1 or 2 commands?
Peter Recore
very much like this idea. that will keep 1 developer busy :) still need some work for the other 3 :)
Ash M
Unit testing: you get the infrastructure out-of-the-box with something like NUnit though, particularly if you're using ReSharper or similar which has nice VS integration for the tests. Setting up continuous integration is a good idea, though, if you have VM capacitiy to host it on.
Rup
A: 

A previous job encountered a little down time while the business sorted out what the next version should be. There were a few things we did that helped

  • Migrated from .net reoting to WCF
  • Searched for pain points in the code that all devs just hate to work with and refactor them
  • Introduce a good automated build system that would run unit tests and send out emails for failed builds. It would also package and place that version in a shared directory for the QA to pick up
  • Scripted the DB so that you can easily upgrade the database rather than being forced to take an out of date copy polluted with irrelevant data that other devs have been playing with.
  • Introduced proper bug tracking and triage process
  • Researched how we could migrate from winforms to wpf
  • Looked at CAB (composite application) or plugin frameworks so configuration would get simplier. (At that time setup and configuration was a tremendous amount of time)

Other things I would do now might be

  • Look at Postsharp to weave cross cutting concerns which would simplify logging, exception handling or anywhere code was repeated over and over again
  • Look at Automapper so that conversions from one type to another was driven by configuration rather than changing code in many places.
  • Look at education around TDD (if you dont do it) or BDD style unit tests.
  • Invest time in streamlining automated integration tests. (As this one is difficult to set up and configure manually it tends to get dropped of within SDLC)
  • Look at the viability on dev tools such as Resharper

HTH

aqwert
refactoring, automated builds, and db scripts are v good propositions. We already practice the rest tho, including postsharp and automapper, tdd, etc. thanks for the feedback
Ash M
A: 

My attitude is that one should almost never write standard libraries. Instead, one should refactor existing, working code to remove duplication and improve ease of use and ease of testing.

The result will be very much like a "standard library", except that you will know that it works (you reran your unit tests after every change, right?), and you'll know that it will be used, since it was already being used. Otherwise, you run the risk of creating a wonderful standard library that isn't used and doesn't work when it is used.

John Saunders
not sure if i agree with you. Having worked at a consultanct/software house before, whenever we embark on a new project, we threw in the standard libraries and a few config, and logging, exception handling and exception reporting worked "right away". Its the kind of thing that would give you an edge when push comes to shove against a tight deadline.
Ash M
I disagree, here. There is a ton of oppurtunity to write "framework" (vs. "application") code. If done right, many projects will see the benefit!
Robert Seder
I agree completely John - Writing code that isn't used is a waste of time. Writing code that you have no clear use cases for is doomed to fail. And anyone who claims to be able to predict the future should send me some winning lotto numbers. I do want to chime in that making your code easily buildable and testable is a great use of time, and falls under "refactoring existing code".
Philip Rieck
Do the refactoring after each project, to _create_ and maintain your standard library. Then include it on each project. That way you get your library, and you'll know it's useful and that it works.
John Saunders
The trouble is that if you're a bespoke software company generally all of the code you've just written belongs to your customer. You can't reuse it - unless you wrote it off-contract in a period of downtime like this. You can at least learn from the last project's version, though.
Rup
+3  A: 

Some of the major things we do:

  • Logging (with some wrappers around TraceSource)
  • Serialization wrappers (so you can serialize/deserialize in one line of code)
  • Compression (wrappers for the .NET functionality, to make it so you can do this in one line of code)
  • Encryption (same thing, wrappers for .NET Framework functionality, so the developer doesn't have to work in byte[]'s all the time)
  • Context - a class that walks the stack trace to bring back a data structure that has all the information about the current call (assembly, class, member, member type, file name, line number, etc)
  • etc, etc...

Hope that helps

Robert Seder
+1  A: 

Here is one thing that can keep all developers busy for a month:

  1. Run your apps' unit tests in a profiler with code coverage (nUnit or VS Code Coverage).
  2. Figure out which areas need more tests.
  3. Write unit tests for those sub-systems.

Now, if the system was not written using TDD, chances are it'd be very monolithic and will require significant refactoring to introduce test surfaces. Hopefully, at the end of it you end up with a more modular, less tightly coupled. more testable system.

Igor Zevaka
very much like the code coverage tests. thinking we can also include some performance tests against our code-base and address any problem areas as they arise. thank you.
Ash M
+3  A: 

ok, most importantly, don't reinvent the wheel!

Spend some time researching libraries which you can easily leverage:

  • For logging I highly recommend Log4Net.
  • For testing nUnit
  • For mocking, Rhino.

Also, take a look at Inversion of Control Containers, I recommend Castle Windsor.

  • For indexing I recommend Solr (on top of Lucene).

Next, write some wrappers:

These should be the entry point of you API (common library, but think of it as an API).

Focus on abstracting all the libraries you use internally in your API, so if you don't want to use Log4Net, or Castle Windsor anymore, you can by writing well structured abstractions and concentrating on loosely coupled design patterns.

Adopt Domain Driven Development:

Think of API(s) as Domains and modular abstractions that internally use other common APIs like you common Data Access library.

Suggestions:

I'd start with a super flexible general DAL library, that makes it super easy to access any type of data and multiple storage mediums.

I'd use Fluent nHibernate for the relational DB stuff, and I'd have all the method calls into the you data access implement LINQ, as it's a c# language feature.

using LINQ to query DBs, Indexes, files, xml etc.

andy
+1, although I'd consider Moq and Unity.
TrueWill
cool, thanks, I'll check those out. Any reason why you prefers those?
andy