Thursday, February 17, 2011

Trac and closed source

I'm working on a closed source (for now) project that I'd like to write a wiki and ticket system about. Trac has a well-integrated wiki and bug/issue-tracking system, and has good integration with Subversion. Webfaction offers Subversion, Trac and a whole lot of programmer-friendly options in a web host. So I'm seriously thinking of using Trac for my project.

One thing concerns me though.

How secure is Trac when I remove permissions to view the sources from various Trac groups? Is there a significant chance that any closed source hosted in the linked Subversion instance would leak out through Trac?

Any of you used Trac for closed source before? What were your experiences?

From stackoverflow
  • I'm actually using a Track /Subversion setup through Webfaction for a closed-source project. The configuration of Trac is really just a front end for Subversion, so ultimately it will be dependent on Subversion's security (e.g. the .authz file).

    A plugin (nothing more than a front end) that will help you in your journey of security configuration:

  • Im using the same setups and the solution i am using is to host the trac as a subdomain - trac.mysite.tdl and svn.mysite.tdl then simply use .htaccess and .htpasswd to secure both of these subdomains to known users.

How can I make a non-programming person recognize a good programmer?

Let's assume that I would be a good programmer and I knew that my (non programming) customer will have to decide between me and a competitor. Let's say that I, as an experienced programmer, would obviously see that my competitor is inexperienced and trying to fool the customer with some nice presentations or an expensive suit.

And here is my problem: How can I empower my customer with the aibility to distinguish between a good and a bad programmer? What can I tell or teach him to be able to look a bit behind the scene?

Same problem, other situation: The nice guy from HR has to hire some programmers on his own. How can I brief him?

Here some solutions that seem obvious, but do not work well:

  • Tell the HR guy to send the best 10 candidates to me. (Changing the assumption -- "non programming person" -- is a solution, but not to this problem.)
  • Give the customer 5 questions he should ask the competitor. (Bad style and the customer still has no clue.)
  • Teach the customer how to code. (errrr ... try again please)
From stackoverflow
  • For the latter question: let him explain something. For instance polymorphism or inflexion.

    A good programmer should be able to explain it to a person without any programming skills.

    Nicholas : I'll agree that it might be an okay way to weed out bad programmers, but it isn't exactly a benchmark for "good programmers". I know a few programmers that could explain polymorphism to my grandpa, but that doesn't translate to the quality of their work.
    Jonke : I know people that are good at teaching "generic" programming but they can't write a single line in real application. (Hello World is not a real application).
  • Short answer: You can't. At least, not until you define a "good programmer".

    Without that clarification, I'll take a page from Joel's book and say that the primary qualities of the programmer are pretty easy for a non-programmer to measure: Smart, and gets things done.

    Jonke : I agree but I would like to have "Done, and get things smart" if I can choose.
    MrFox : "getting things done" is hard to decide in the situations above
    Nicholas : MrFox: as a HR hiring rep? I'd hope not.
  • This is a perfect situation when Marketing skills come in handy. This is exactly one of the reasons good programmers need good marketing skills. Otherwise marketers will win. And precisely because marketing is understandable to the layman that we need to compete on that ground and not on programming alone.

    Jeff had a great post about his that came from Steve Y's great speach about this

  • Tell your non-expert that if this guy walks through the door, give him a job.

    S.Lott : Depends on the job. I've read interviews with Knuth and he doesn't seem focused. He might follow his gut and instincts a little too much. Great if you're hiring someone to invent fundamentally new kinds of apps. Maybe not so good for shipping product on schedule.
    Ali A : Yeah, I agree, I was just trying to be funny.
    Ali A : (a deadly game on s.o.)
    Ken Liu : that guy doesn't even use email.
  • In my experience there really isn't a way that you can make a non-programming person realise that your competitor is worse then you, because no matter what you say, the customer has in the back of their mind the fact that you are trying to get the same work as your competitor and that is going to colour their judgement of whatever you say.

    In my experience it is better to simply show the customer your past record of successes vs your competitors past record and then encourage them to ring former clients of both you and them and get their opinions.

  • Just like Nick Baldwin wrote, a non-programmer can't evaluate someone's technical skills and that's why we around here always have some kind of technical expert for interviews.

    S.Lott : Here's a suggestion -- vote up the answer you like. Add comments. But repeating the answer you like can be seen as a waste of time.
    t3mujin : I took Nick's answer to add my own experience: in my company there's always someone with a technical background in interviews.
  • The customer is a person who doesn't need to know if you are a very good programmer. He has a problem and you can help him to fix it...and that's it...if you try to explain him that you are best than your competitor hi won't care! Hi just wants his problem fixed...

    Now you need to convince the customer that you are offering the best solution to his problem and that you will help him to decide what's best for him and his business...if you can do this without mentioning any technologies or languages or frameworks that maybe the customer will pick you.

  • I think you need to describe the qualities that set a good programmer apart from the rest: good communication skills, attention to detail, ability to describe problems from different perspectives, knowledge of business, ability to organize.

    If you think of it, the process of running a SCRUM meeting would be good description of the organizational skill that a programmer possesses. How would the programmer describe a problem that they are encountering, and how is this affecting his / her schedule. Furthermore, can these descriptions be described in business language and with analogies? The mark of a facile mind is one that can switch gears and still communicate.

    On the skill front, when you describe good programming skill to a potential customer, what are those things that make a good programmer? How do design patterns help? How does in depth knowledge of a related system bring dimension and breadth to a developers experience.

    Finally, does the developer have a blog? Maintaining a blog can speak to the level care one takes when maintaining skills.

  • It's all about trust. Does your customer trust you and ask for your opinion? Does HR trust you?

    If they don't trust you, you can't make them or empower them or influence them at all.

    If they do trust you, then your opinion will be of value and you now have the real problem of getting them to ask for your help in choosing a programmer.

    I interview programmers by the dozen. I suspect it isn't because I've got great questions or some profound insight into the programming mind. I interview programmers because my opinion is trusted.

    If you opinion isn't trusted (or isn't trusted enough), what's wrong with your relationship? What aren't you doing? What could you do more of, less of or differently to improve the level of trust.

    Here's one theory: lack of trust can be mutual. Perhaps you don't trust them to do the right thing and it shows. Because you don't trust them, they don't trust you.

  • A couple of people have mentioned things like "define a good programmer".

    A Good Programer is more than the sum of his parts. He will know multiple languages in several disciplines and knows how to use several of them together. He will also know how his skillset interacts with others in a team (e.g. to the DBA or the webmaster) -- he may in fact have the skills to be those other people to some extent. Moreover, he will be able to speak about his experience and achievements using these skills from a position of authority and modesty. A HR person should be able to recognize both of these.

    The other way to answer your original question is that they have to watch someone who knows what they are doing pick good programmers from not good programmers, being aware that this is the skill they are being asked to learn.

  • Show the non-programmer something that will dazzle him, a small demo of a killer application (something very fancy) always gets the job done.

    Edit: if you don't have any killer apps, the you gotta ask yourself if you really are better than the competition. ( Customers want good applications, not bad ones that have great code in them ;-) )

  • Your question is sort of like asking, what makes a good President?

    The answer turns out to be the same as well. Most likely a person is going to be good at a specific task if they have an interest in the job at hand, experience, a good work ethic, can communicate, and are intelligent. While all those are very general qualities and do little to identify the specific toolset that a programmer might need, they certainly lay the groundwork for the ability to learn and comprehend specific areas like programming.

    You can't inform others about the specific qualities of a complicated domain (i.e. programming) without at least knowing that they know something about the domain. So the most logical thing to do is rely on the thing people have been doing for generations: judge the overall qualifications of the candidate.

  • This is where being able to articulate your accomplishments come in handy. Explain in detail, but in a fashion that is understandable to non-technical folks what projects you've been a part of, your part in the project, what you did, and why what you did was so great.

    When you're trying to sell your self (in an interview or trying to land a contracting job), the interviewer knows that you are directly competing with other people. You saying "I am better than the other guy" or "the other guy stinks" means nothing to them, because you are competing with the other guy and the interviewer expects you to compare yourself more favorably to your competition.

    But if you are truly a good programmer, your accomplishments will be more impressive than your competition's accomplishments and the interviewer will take notice.

  • Don't compete with your competitors on direct technical skills. While they're burbling on about ASP.NET or whatever, you can explain how you would add real value to the business.

    In other words, cut out the technical muddle and go direct to the business problem.

  • A good portfolio of your past work can do most of the talking for you. It has worked for me on a couple of occasions, and I think to a non-programmer, seeing might be believing - if what you show is genuine and good.

  • One thing I've done in the past to help a non-programmer manager in the hiring process is to set up a short test covering some of the fundamentals I'd expect a "good programmer" (for that particular role) to be able to cover pretty easily.

    It worked surprisingly well - some people interviewed well, but bombed in the (not too difficult) test. Some interviewed so-so, but blitzed the test.

    When faced with two people who both interview well, when one scores 5/25 and the other scores 23/25, you know who you're going to more inclined to offer the job to..

    I know it's far from perfect, but it's actually worked so well for me that I'm now disappointed when I go to job interviews and they don't test me in any way. In fact, in almost 10 years in my industry I've never been tested in any way, shape or form when applying for a new job.

Best practices for refactoring classic ASP?

I've got to do some significant development in a large, old, spaghetti-ridden ASP system. I've been away from ASP for a long time, focusing my energies on Rails development.

One basic step I've taken is to refactor pages into subs and functions with meaningful names, so that at least it's easy to understand @ the top of the file what's generally going on.

Is there a worthwhile MVC framework for ASP? Or a best practice at how to at least get business logic out of the views? (I remember doing a lot of includes back in the day -- is that still the way to do it?)

I'd love to get some unit testing going for business logic too, but maybe I'm asking too much?

From stackoverflow
  • Is there any chance you could move from ASP to ASP.Net? Or are you looking at keeping it in classic ASP, but just cleaning it up. If at all possible, I would recommend moving as much as possible moving to .Net. It looks like you may be rewriting/reorganizing a lot of code anyway, so moving to .Net may not be a lot of extra effort.

  • There are over 200 ASP scripts in the project, some thousands of lines long ;) UGH!

    We may opt for the "big rewrite" but until then, when I'm in changing a page, I want to spend a little extra time cleaning up the spaghetti.

  • Since a complete rewrite of a working system can be very dangerous i can only give you a small tip: Set up exuberant tags, ctags, on your project. This way you can jump to the definition of a function and sub easy, which i think helps a lot.

    On separating logic from "views". VBScript supports som kind of OO with classes. I tend to write classes which do the logic which I include on the asp-page which acts as a "view". Then i hook together the view with the class like Username: <%= MyAccount.UserName %>. The MyAccount class can also have methods like: MyAccount.Login() and so on.

    Kind of primitive, but at least you can capsulate some code and hide it from the HTML.

  • Presumably someone else wrote most or all of the system that you're now maintaining. Look for the usual bad habits (repeated code, variables that are too widely scoped, nested if statements, etc.), and refactor as you would any other language. Keep an eye out for recurring things in the same file or different files and abstract them into functions.

    If the code was written/maintained by various people, there might be some issues with inconsistent coding style. I find that bringing the code back into line makes it easier to see things that can be refactored.

    "Thousands of lines long" makes me suspicious that there may also be situations where loosely-related things are being displayed on the same page. There again, you want to abstract them into separate subroutines.

    Eventually you want to be writing objects to help encapsulate stuff like database connectivity, but it will be a while before you get there.

  • Assumptions

    The documentation for the Classic ASP system is rather light.

    Management is not looking for a rewrite.

    Since you have been doing ruby on rails, your (VB/C#) ASP.NET is passable at best.

    My experience

    I too inherited a classic ASP system that was slapped together willy-nilly by ex excel-vba types. There was a lot of this stuff <font size=3>crap</font> (and sometimes missing closing tags; Argggh!). Over the course of 2.5 years I added a security system, a common library, CSS+XHTML and was able to coerce the thing to validate xhtml1.1 (sans proper mime type, unfortunately) and built a fairly robust and ajaxy reporting system that's being used daily by 80 users.

    I used jEdit, with cTags (as mentioned by jamting above), and a bunch of other plugins.

    My Advice Try to create a master include file from which to import all the stuff that's commonly used. Stuff like login/logout, database access, web services, javascript libs, etc.

    Do use classes. They are ultra-primitive (no inheritance) but as jamting said, they can be convenient.

    Indent the scripts properly.


    Write an external architecture document. I personally use LyX, because it's brain-dead to produce a nicely formatted pdf, but you can use whatever you like. If you use a wiki, get the graphviz add-in installed and use it. It's super easy to make quick diagrams that can be easily modified.

    Since I have no idea how substantial the enhancements need to be, I suggest having a good high-level to mid-level architecture document will be quite useful in planning the enhancements.

    On the business logic unit tests, the only thing I found that works is setting up an xml-rpc listener in asp that imports the main library and exposes the functions (not subroutines though) in any of the main library's sub-includes, and then build, separately, a unit test system in a language with better support for the stuff that calls the ASP functions through xml-rpc. I use python, but I think Ruby should do the trick. (Does that make sense?). The cool thing is that the person writing the unit-test part of the software does not need to even look at the ASP code, as long as they have decent descriptions of the functions to call, so they can be someone beside you.

    There is a project called aspunit at sourceforge but the last release was in 2004 and it's marked as inactive. Never used it but it's pure vbscript. A cursory look at the code tells me it looks like the authors knew what they were doing.

    Finally, if you need help, I have some availability to do contract telecommuting work (maybe 8 hours/week max). Follow the link trail for contact info.

    Good luck! HTH.

  • My advice would be to carry on refactoring, classic ASP supports classes, so you should be able to move all everything but the display code into included ASP files which just contain classes. See this article of details of moving from old fashioned asp towards ASP.NET

    Refactoring ASP

    Regarding a future direction, I wouldn't aim for ASP.NET web forms, instead I'd go for Microsoft's new MVC framework an add-on to of ASP.NET) It will be much simpler migrating to this from classic ASP.

    nocache : or since you are familiar with RoR, then you should look into Castle Monorail as an alternative to Microsoft ASP.NET MVC. They are both quite mature now, but Monorail was there first, and it integrates nicely with the Castle ActiveRecord implementation, so it might be easier to pick up and the Microsoft MVC stack.
    Tristan Havelick : The author of this answer should disclose that he is the author of the pay-to-view article he links to here. For $8, it doesn't cover much of anything you won't find in Fowler's book, or Feather's.
  • I use ASPUnit for unit testing some of our classic ASP and find it to be helpful. It may be old, but so is ASP. It's simple, but it does work and you can customize or extend it if necessary.

    I've also found Working Effectively with Legacy Code by Michael Feathers to be a helpful guide for finding ways to get some of that old code under test.

    Include files can help as long as you keep it simple. At one point I tried creating an include for each class and that didn't work out too well. I like having a couple main includes with common business logic, and for complicated pages sometimes an include with logic for each of those pages. I suppose you could do MVC with a similar setup.

  • This is very old, but couldn't resist adding my two cents. If you must rewrite, and must continue to use classic ASP:

    • use JScript! much more powerful, you get inheritance, and there some good side benefits like using the same methods for server-side validation as you use for client-side
    • you can absolutely do MVC - I wrote an MVC framework, and it was not that many lines of code
    • you can also generate your model classes automatically with a bit of work. I have some code for this that worked quite well
    • make sure you are doing parameterized queries, and always returning disconnected recordsets

Message Driven Bean with a Datasource

My question is how do I configure an EJB 3.0 style message driven bean to use a configured JMS datasource in jboss.

For example, my MDB looks something like:

@MessageDriven(mappedName = "ExampleMDB", activationConfig = {

        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"),
        @ActivationConfigProperty(propertyName = "destination", propertyValue = "MyTopic"),
        @ActivationConfigProperty(propertyName = "channel", propertyValue = "MyChannel"),

@ResourceAdapter(value = "wmq.jmsra.rar")
public class MyMDB implements MessageListener {

But I would like the bean to attached to a given JMS datasource ( in the case of jboss 4.2.2 this is in deploy/jms/jms-ds.xml). Perhaps this is not even possible but is worth asking.

From stackoverflow
  • If I understood your problem correctly, MyMDB listens to a topic on WebLogic, and you want to use an additional JMS destination provided by JBoss, defined in a deployed configuration file and identified by its JNDI name (by default, deploy/jms/jms-ds.xml only contains the configuration for the JMS provider and connection factories -- no data sources).

    The easiest way is to let the container inject the JMS destination and a connection factory via its JNDI name (in JBoss the JMS destinations are configured by deploying xxx-service.xml files). On startup you can then initialize the connection, and perform cleanup as soon as the MDB is released.

    The following examples shows injection (@Resource) and resource managemend (@PostConstruct and @PreDestroy). The JMS connection and destination is used in useJmsDestination(String) to send a text message.

    public class MyMDB implements MessageListener {
     @Resource(mappedName = "queue/YourQueueName") // can be topic too
     private Queue targetDestination;
     @Resource(mappedName = "QueueConnectionFactory") // or ConnectionFactory
     private QueueConnectionFactory factory;
     private Connection conn;
     public void onMessage(Message m) {
      // parse message and do what you need to do
      // do something with the message and the JBoss JMS destination
     private void useJmsDestination(String text) {
      Session session = null;
      MessageProducer producer = null;
      try {
       session = conn.createSession(true, Session.AUTO_ACKNOWLEDGE);
       producer = session.createProducer(targetDestination);
       TextMessage msg = session.createTextMessage(text);
      } catch (JMSException e) {
       throw new RuntimeException(e);
      } finally {
       try {
        if (producer != null) {
        if (session != null) {
       } catch (JMSException e) {
        // handle error, should be non-fatal, as the message is already sent.
     void init() {
      // other initialization logic
     void cleanUp() {
      // other cleanup logic
     private void initConnection() {
      try {
       conn = factory.createConnection();
      } catch (JMSException e) {
       throw new RuntimeException("Could not initialize connection", e);
     private void closeConnection() {
      try {
      } catch (JMSException e) {
       // handle error, should be non-fatal, as the connection is being closed

    I hope this can help you.

  • I think what you are asking is "How do I specify the JNDI location of the JMS datasource to use for an MDB?"

    In which case the answer is:

    @ActivationConfigProperty(propertyName = "providerAdapterJNDI", propertyValue = "java:/DefaultJMSProvider")

    Also, take a look at the following page which provides loads of useful details on configuring MDBs in jBoss:

How do I export a CSV from Access?


I am trying to import an access database to mysql. I have created a mysql database, but do not want to use all of the colums in the access database. Is there a way to export only certain colums from the access database to csv?

From stackoverflow
  • 1) Make a query on the table with only the columns you want, and save it.
    2) Select the query, and then got to File->Export (Select Save As "text *.txt, *cvs, etc.") and follow the prompts

Is it worth switching from Visual Studio 2005 to Visual Studio 2008 ?

As a team we are using Visual Studio 2005 with framework 3.0. I am thinking if it will be nice for us to switch to Visual Studio 2008 with framework 3.5 ? Is it worth it ?


From stackoverflow
  • Yes, it is 100% worth it. Visual Studio 2008 supports 2005 code (.net 2.0) completely. There are also a lot of improvements that you'll enjoy as you use 2008.

    Marc Gravell : Actually it targets 2.0 SP1 (and similar for 3.0), meaning you can get into issues if you aren't careful. But I agree completely: make the switch!
    korro : "Yes it is worth it, there are a lot of improvements". That's really all the arguments you need??
  • 100% worth it, agreed.

    Also switching to 3.5 with new projects (or easy to migrate ones) will help a lot with productivity. Even it you don't use features like LinQ.

    Object Initializers and Automatic Properties will make your life much easier.

    Also as said before, you can still develop 2.0 projects with VS 2008, so switching won't hurt at all. There have been some improvements in the Webdesigner space, especially with Javascript Syntaxhighlightning etc..

  • Thanks for your answers; They helped me.


  • Multi-Targeting support (utilization of Dev Studio 2008 for all .Net project, without having to convert them)
    Refactor (Productivity tools / Macro )
    Unit Test (Pro only)
    Better Web Designer with improve Editing and CSS Support
    CSS Source View Intellisense
    Transparent Intellisense (don’t hide code behind)
    JavaScript support with Intelissense
    JavaScript Debugging
    Windows Presentation Foundation (WPF) Designer LINQ (Language INtegrated Query)
    Object Relational Designer (O/R Designer)
    Better debbuging capabilities (Multithread, script, LINQ, WPF)
    Debug Remote process, SQL Debug, XSLT Debug (Professional version only)
    New reporting tool (with PDF support)
    Crystal report new feature (also ASP.NET) (Pro version only)
    Community help (comment added by user in online help)
    ClickOnce Deployment enhancement (setup)
    Better Vista support
    Office support (Pro version only)
    Many tools for smart device (Pro version only)

    With Dev Studio 2008 SP1

    Support for Smart Device Occasionally connected Application
    Power Packs Controls and components
    Printer Compatiblity Library (use VB6 report without rewriting them)


  • Even if you can't use .NET 3.5 yet, the C# 3.0 language features (especially if you use LINQBridge) are well worth it. It also has better support for WCF etc (since you mention 3.0 - this is a kludge in VS2005).

    Add to that the IDE improvements, and it is a no-brainer IMO.

  • The intellisense for C# is much improved

  • yes it is. works faster and more reliable

What do you like about Django?

I started to learn Django a few days ago, and as i dive into it it seems that I'm starting to like it even more.
Trying to migrate from other language. I won't say which one, as the purpose of this question is not to bash anything.

So i would like to know your opinion about Django.

What do you like about it?
What made you switch/use it?
What features you would like it to have that aren't there?
What would make you switch to it?
How fast is it in production?
How hard is it to master it?

From stackoverflow
  • What do I like about it :

    • Very simple ORM
    • clear separation of template / controller
    • django-admin
    • pluggable apps : it seems to me that the Django community really nailed that one !

    What made me switch :

    • mainly curiosity
    • I heard a lot of good things about it from a colleague
    • I wanted something more lightweight than the Java I do for a living
    • I had a side project heavily data-driven for which the Django-Admin interface is very useful

    What features I'd like :

    • better / simpler control of the transactions (configuring different types of transactions (read only / read write / some tweaking here and there) isnt as easy as i am used to. Having a session in view model, where the transaction is still open in the view doesnt make me all that comfortable, I would prefer if the transactions didnt leave a service layer. But again, there isnt really a service layer in the Django model.
    • better model for business logic (maybe that's just me, but I miss the service oriented approach of enterprise java, I never know if I should put the business logic in the view, in the form or in the model. None of those solution make me feel warm and fuzzy ... at the same time, I dont have heavy business logic in the application I develop for the moment, and I would probably still use Java for those)
    • stability (in the sense of not changing, not in the sense of not crashing). Again, coming from Java, where I'm still working on Java 1.4 for a lot of projects, having a project that just released 1.0 and all the refactoring that went with it is not very reassuring. It did take some work to follow trunk and using 0.96 was not particularly compelling. I dont think I would feel comfortable to use it on a mission critical enterprise project yet.

    I realize that there is quite a few improvements that I would like. Dont understand me wrong, I love Django and I will stick to it for a lot of projects. I jsut wont put it everywhere yet ...

  • What do you like about it?

    URL dispatching: I was never a big fan of "/foo.php" is the file "foo.php" on my server, and if I want nicer URLs I need to mess around with mod_rewrite and keep that in line with what my logic in foo expects.

    ORM: Because 90%+ of your queries, in my experience, do not need to be written by hand. Smart caching is much more important for performance, in general. You can always drop to raw SQL as needed.

    Middleware and Signals: Easy to extend most parts of the request / response / view / render cycle without touching Django code itself.

    What made you switch/use it?

    It came out when I was disappointed with the Python web framework offerings. An easy sell for me.

    How fast is it in production?

    Hmm, to be honest, I've never cared too much. The webserver part of your app is (in my opinion) always the easiest to scale. As long as you use 'best practices' and share nothing, all you need to do is add a software load balancer and you can add new webservers until the cows come home. The first bottleneck people generally hit is database load - but Django gives you great caching APIs that help you alleviate that.

    That said, I only skimmed this but it seems faster than Rails and the well known PHP frameworks:

    How hard is it to master it?

    I guess it depends how you define 'master'. The documentation is great, over the course of a decent sized site/app I think you'll use a little bit of everything, which is a great start.

    daniels : "URL dispatching" i love it too
  • I haven't had had the opportunity to use it much. That said, my absolute favorite part of django is the built in administration console.

  • Likes

    The excellent Documentation. Together with help from stackoverflow I have learned a lot in only a few days. It writting in Python. It has the wonderful contrib.admin which is even modular and extensible to embed it into the web app proper.


    None so far. I am still enchanted


    Its my first web framework, so no switch. After using Python for some years Django seemed the natural selection to me, mainly for its clean design.

    TomA : Indeed, without the top-notch documentation Django would not be quite as attractive.
  • What do you like about it?

    • the templates, specifically the inheritance feature, was amazing after dealing with jsps
    • not having to write sql anymore

    What made you switch/use it?

    A friend had been following its progress before it was publicly released, and I've been using it for personal projects ever since.

    What features you would like it to have that aren't there?

    I realize this isn't a trivial problem, and I think Google summer of codes have been spent on this, but I would like to see better ways to evolve the db (which rails seems to do a pretty good job of).

    What would make you switch to it?

    I already use it at home, and I don't make those decisions at work.

    How fast is it in production?

    I've never run into issues, though for the most part django seems to stay out of the way, so performance seems based more on python or the db.

    How hard is it to master it?

    The documentation is pretty amazing, and enough people use it that answers are often available when that doesn't help. Additionally, when I've had to go into the source code, its been clean and documented as well, so I would say its easier to master than most frameworks, web based or otherwise.

  • Likes:

    • Pythonic (I can easily grok the language) and thus extend any part easily
    • Documentation,
    • community (I belong to the french one and they're very nice)
    • a full load of projects around it
    • full-integrated test engine. You can almost test a whole application without firing a web browser, just by writing tests.
    • the custom commands just rock. It allows you to perform custom tasks very easily, in a snap. I often use it to run batch tasks (cleanup a database, for example, or check for integrity on a production server - tests use their own database, not the actual data in your application).

    Why switch?

    • got bored of PHP-from-scratch.
    • had a RSI at the back of my hand, very painful. after switching to a semicolon-free language, it vanished (it's TRUE!)
    • much more solid developpement (TDD), and faster (you can buid a CMS in minutes) - as many other web framework, though.


    • no smooth data model migration. You often have to change your model because of an unexpected feature. That is painful, and you have to build it by hand, and it may be risky sometimes.

    How hard to master?

    • If you already have Python skills, you can build up things in a few hours.
    • If you don't, first dive into Python (heh) - that'd take a few days.
    • "Mastering" it may take some time... And you often discover gems in Django documentation that will make you yell "I love Django!" (well, it works for me)

How do I round corners of myapp's icon

In simulator mode, myapp has an icon with round corners, but on real iPhone, the corners arn't rounded.

From stackoverflow
  • Hello DFG, by default the iPhone should round your corners and add a reflection effect. Be sure you have not added the UIPrerenderedIcon key to your Info.plist file. Hope this helps!


    DFG : UIPrerenderedIcon is not in my Info.plist.
    Adam Alexander : Unfortunately I would think that indicates your environment is not working as designed, but someone else here who knows something I don't may be able to provide additional insight.
  • Corners get automatically rounded if you install via MobileInstallation (from iTunes, Xcode or App Store). If you're building the package and installing it into /Applications manually or with cydia/apt, you have to make a rounded icon yourself.

    You can find the images used to round the corners and add reflection in /System/Library/Frameworks/UIKit.framework/Other.artwork, the first 3 images are the mask, reflection and shadow. You can extract the .artwork file with this script here

Counting the number of unique image occurences in a DataGridViewImageColumn

In a DataGridView bound to a DataView, where cells in a column will contain one of two images from an ImageList (e.g. a green 'online' image or a red 'offline' image), how can you sum the number of occurences of each image when iterating through the DataGridView's rows?

The Value and FormattedValue properties of DataGridViewImageCell return different references even though the entries in the underlying DataTable were created by referencing the same Image from the ImageList.

So rather than it counting 4 occurences of 'online' and 6 occurences of 'offline', I'm getting 10 occurences of alledgedly different images.

From stackoverflow
  • Given the description, the best I can suggest is to manually track the image key/index in the .Tag of the cell, and then run your distinct count on the .Tag. Alternatively, if you also have the data in a list/collection, count the data from the original source.

    [update following reply] Since the data is data-bound, you should be able to iterate the .Rows of the DataGridView, obtaining the .DataBoundItem of each. Then for each underlying object, you should be able to obtain the actual property value using TypeDescriptor:

            string propName = col.DataPropertyName;
            // could also be a dictionary/hashset etc
            // could be typed if you know the type
            List<object> values = new List<object>();
            foreach(DataGridViewRow row in dgv.Rows)
                object obj = row.DataBoundItem;
                // could be typed (via cast) if you know the type
                object val = TypeDescriptor.GetProperties(obj)[propName].GetValue(obj);
                if (!values.Contains(val))

    That any help?

    frou : Hi Marc - thanks for the reply. At what point would you assign to the Tag property of the cell seeing as the DataGridView is data bound and auto-populates itself?
    frou : + The DataGridView is showing a subset of the entire DataTable (using DataView.RowFilter) and within that I only want to count within the currently highlighted rows (MultiSelect). So back-tracking to the original data source seems difficult
    Marc Gravell : I'll update to indicate...
    frou : It looks like the bitmaps must be duplicated in memory for every row because using your approach, the bitmap references that come back are different for every row, even if they are using the same image from the image list.
    frou : + I'll have to rethink this because I don't want to end up doing pixel level equality tests! Thanks for your answer though, it definitely seems like it should work. I wish I could give you more points but I can't mark it as the answer

Variable number of results from a function

I have code similar to the following in many places:

var dbParams = db.ReadParams(memberID, product, GetSubscriptionFields());
Debug.Assert(dbParams.Count == 4);

_memberCode = dbParams[0];
_password = dbParams[1];
_userName = dbParams[2];
_reasonCode = dbParams[3];

ReadParams() returns an array of strings, the number of strings depending on the GetSubscriptionFields() function. I could use dbParams[] directly in my code, but I find it more helpful to give meaningful names to each of the values in the array. Is there a way I can get all the results directly, without going through the array?

I am looking for something like:

db.ReadParams(memberID, product, out _memberCode, out _password, out _userName, out _reasonCode);


Tuple<_memberCode, _password, _userName, _reasonCode> = db.ReadParams(memberID, product);

Of course, it has to be legal C# code :)

From stackoverflow
  • Why not use constants instead?

    Then in your code you could have


    which meets your goal of meaningful names without changing the way the method works.

    Marcel Popescu : I like this idea, it's simpler to implement than Mecki's.
  • I think your Tuple idea is pretty good. You could define it like this:

    public class Tuple<T1, T2, T3, T4>
        public T1 Field1 { get; set; }
        public T2 Field2 { get; set; }
        public T3 Field3 { get; set; }
        public T4 Field4 { get; set; }

    You would probably want to define a few of those, with two and three properties. Unfortunately it doesn't help you naming the properties of the class. There really is no way to do that (at least not until C# 4.0, when you could use dynamic typing with an anonymous type.

    Marc Gravell : It is still essentially positional, though - i.e. accessing result.Field1 isn't much different from accessing result[0] (assuming they are like-typed)
    Ch00k : You are correct, but there are some other benefits that you get. For example, if you write the appropriate constructor and limit the properties to read only, then you at least get a guarantee that you will get the right number of values back.
  • Not really; since the number of arguments isn't fixed, there isn't really a better way of doing it. The problem with regular tuples is that you are still working positionally - just with ".Value0" instead of "[0]". And anonymous types can't be directly exposed in an API.

    Of course, you could subsequently wrap the values in your own class with properties, and just do a projection:

     return new Foo {MemberCode = arr[0], ...}

    (where Foo is your class that represents whatever this result is, with named, typed properties)

    Alternatively you could throw them into a dictionary, but this doesn't help the caller any more than an array does.

    The only other option is something really grungy like accepting a params array of Action<string> that you use to assign each. I'll elaborate on the last just for fun - I don't suggest you do this:

    static void Main()
        string name = "";
        int value = 0;
            x => { name = x; },
            x => { value = int.Parse(x); });    
    // yucky; wash eyes after reading...
    static void Foo(string query, params Action<string>[] actions)
        string[] results = Bar(query); // the actual query
        int len = actions.Length < results.Length ? actions.Length : results.Length;
        for (int i = 0; i < len; i++)
  • You are writing code in a highly object oriented language, so why don't you use objects?

    Member m = db.ReadParams(memberID, product, GetSubscriptionFields());

    and in your code you use


    Of course you don't have to make the values publicly accessible, you can make them only accessible via setter/getter methods, and by only having getters, you can avoid them from being altered after object creation.

    Of course different calls to db.ReadParams should return different objects, e.g. you can create an abstract base class and inherit all possible results from db.ReadParams of it. Therefor you may have to encapsulate db.ReadParams into another method that finds out the right type of object to create:

    ReadParamsResult rpr = myDb.ReadParamsAsObject(memberID, product, GetSubscriptionFields());
    // Verify that the expected result object has been returned
    Debug.Assert(rpr is Member);
    // Downcast
    Member m = (Member)rpr;
    Marcel Popescu : Very good idea, thanks. For now I'm going with the other one though because it's simpler and faster to implement, but I appreciate this and I might use it later.
  • I also came up with this... I kinda like it most, but it's a personal preference, I understand it's definitely not the cleanest idea:

    using System.Diagnostics;
    public static class ArrayExtractor
      public static void Extract<T1>(this object[] array, out T1 value1)
          where T1 : class
        Debug.Assert(array.Length >= 1);
        value1 = array[0] as T1;
      public static void Extract<T1, T2>(this object[] array, out T1 value1, out T2 value2)
          where T1 : class
          where T2 : class
        Debug.Assert(array.Length >= 2);
        value1 = array[0] as T1;
        value2 = array[1] as T2;

    Of course, I am extending this class up to 10 or 15 arguments.


    string fileName;
    string contents;
    ArrayExtractor.Extract(args, out fileName, out contents);

    or even better

    args.Extract(out fileName, out contents);

    where args is, of course, an object array.

What's the proper naming convention for a property 'ID' : ID or Id ?

Pretty simple question: When i have a persistable object, it usually has a property called ID (for abstract classes).

So .. is the naming convention ID or Id?


public int ID { get; set; }


public int Id { get; set; }

cheers :)

PS. This is for .NET btw. FXCop conformat would be a bonus.

From stackoverflow
  • I prefer ID, also in combination with other words (e.g. CustomerID), but strictly speaking that is against the regular naming conventions.

  • We use ID internally, because Id seems to me like psychology speak, but FxCop complains, as ID is not an acronym, its an abbreviation (for Identity/Identifier). According to the FxCop rule, only acronyms that are two characters long are allowed to be all caps. Everything else should be Proper case.

    We put a SuppressMessage attribute on the ID property, and everyone is happy.

  • Whatever you like it to be, just be consistent. ID is not a word, it's an abbreviation of identity. How to write abbreviations is something people argue about for a long time. E.g. is it




    actually both can be found in use in different frameworks. Another popular abbr. with similar problem is UTF8.

    It's just important to be consistent, because otherwise people always have to look up the correct capitalization for every method, if every method handles it in a different way.

    I have my own convention for that. If the abbr. is at the end of the name, it is all capitalized, if it's somewhere else, it follows camel notation rules. E.g.


    Why? I like abbr. to be capitalized. Most people expect URL or UTF to be capitalized. However, if in the middle of a name, it destroys the advantage of camel notation. The advantage of camel notation is that you see where a new word starts by capitalization. So compare:


    In the first case, I don't see immediately the URL is one word and To is the next one. The T might be part of URL (URLT) and be a different abbr., thus I'll use the second form. If it's at the end however, it won't play a role, no other word follows, thus I prefer the capitalized form. I stick to this convention throughout all of my code.

  • I usually go with Identifier. If I really want to keep it short (as part of a longer identifier, for example), I use Id, unless it's a parameter or private member.

    The .NET Framework Naming Guidelines say this:

    An acronym is a word that is formed from the letters of words in a term or phrase. For example, HTML is an acronym for Hypertext Markup Language. You should include acronyms in identifiers only when they are widely known and well understood. Acronyms differ from abbreviations in that an abbreviation shortens a single word. For example, ID is an abbreviation for identifier. In general, library names should not use abbreviations.

    The two abbreviations that can be used in identifiers are ID and OK. In Pascal-cased identifiers they should appear as Id, and Ok. If used as the first word in a camel-cased identifier, they should appear as id and ok, respectively.

  • We around here see things like "Id" or other acronyms as a word, and "Id" is the easy one because in the banking business we do get lots of strange letter combinations. So we treat it as a word, only with the first letter capitalized, and that's how we ended up being defined in our internal coding conventions paper.

    But the bottom line is: choose what convention is more comfortable for the developer team and other people that look at the source code and stick with it.

  • The guidelines say "Id".

    Fortunately the the .Net guys were king enough to give us "naming guidelines" and not "naming laws" ;), so basically if you strongly feel that breaking a guideline rule does add more value than following it, then by all means break it, no one will take you accountable for it if they understand your reasons (like it provides more readability and accentuates the meaning of the name)

    In my shop we use 'ID' even if the guidelines say 'Id', but no one, really feels guilty about it.

  • As others pointed out, Id is right according to .NET conventions, but somehow it doesn't feel right, so many people use ID (and still live).

    I don't know what the content of your field will be (numbers, strings, guids), but if you want to skip the problem you may simply use another .NET convention for object identifiers: Name

  • "ID" is one of abbreviations hardcoded in FxCop naming rules that are always considered wrong spelled even if they are parts of other words. The only way I found to override it is adding "ID" to Acronyms as (): ID

    It worked with FxCop 1.36. P.S. In general, I think that "Id" is a better alternative but sometimes it's impossible to change a name if it's generated based on XML files (or web services) which we don't control


    Why fight it?

Deleting records in LINQ with foreign keys - invalid cast exception

I have a simple database:

ArticleId (PK),
..other stuff...

ArchiveId (PK),
..other stuff...

The articleId's are foreign keys.

I want to be able to delete a user article row by UserArticleId using the following code

  UserArticle myobjtodelete = PersonalArchiveDb.UserArticles.Single(ua => ua.ArchiveId == 3);


(yes i am aware i can do the statement inside the delete rather than retrieving the object, it was for debugging to make sure the object definitly exists - it does)

When the debugger hits the SubmitChanges() line, I get a runtime error:

Specified cast is not valid.

Here is the stack trace

at System.Data.Linq.IdentityManager .StandardIdentityManager .SingleKeyManager\2.TryCreateKeyFromValues(Object[] values, V& v) at System.Data.Linq.IdentityManager.StandardIdentityManager.IdentityCache2.Find(Object[] keyValues) at System.Data.Linq.IdentityManager.StandardIdentityManager.Find(MetaType type, Object[] keyValues) at System.Data.Linq.CommonDataServices.GetCachedObject(MetaType type, Object[] keyValues) at System.Data.Linq.ChangeProcessor.GetOtherItem(MetaAssociation assoc, Object instance) at System.Data.Linq.ChangeProcessor.BuildEdgeMaps() at System.Data.Linq.ChangeProcessor.SubmitChanges(ConflictMode failureMode) at System.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode) at System.Data.Linq.DataContext.SubmitChanges() at Driver_SOC_ASO.Controls.PersonalArchive.ArchiveListing.grdArchive_RowDeleting(Object sender, GridViewDeleteEventArgs e) in C:\work\Driver.Net\Driver-SOC-ASO\Driver-SOC-ASO\Controls\PersonalArchive\ArchiveListing.ascx.cs:line 78 at System.Web.UI.WebControls.GridView.OnRowDeleting(GridViewDeleteEventArgs e) at System.Web.UI.WebControls.GridView.HandleDelete(GridViewRow row, Int32 rowIndex) at System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) at System.Web.UI.WebControls.GridView.RaisePostBackEvent(String eventArgument) at System.Web.UI.WebControls.GridView.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

I am at a loss, any ideas?

From stackoverflow
  • Your user-article table may be updated and you forgot to update the dbml?

    qui : No, that's not the case.
  • try setting ON CASCADE DELETE for ArticleId

  • This may be an example of this bug, which Microsoft says is fixed in .NET 4.0.

  • Is ArticleId an integer, or compatible with it?

  • In your dbml, check to see if there is incorrect an association b/w Article and UserArticle.

Table header background image tiling vertically

I have a gradient image as a background for a table header(9x18pix). This image is called through a selector class. When the header content grows to 2 lines(vertical height increases), the bg image is tiling vertically and looks ugly. How can I stretch the bg image vertically without tiling?

From stackoverflow
  • You can't stretch it. Well not without some nasty CSS hacks, that will not really work in all available browsers. I wouldn't use them (unless your HTML code only targets a single browser, e.g. if it's a page for internal use and the browser being used is known). You can make it repeat in just one direction, though. This is what you usually want when having a gradient.

    background-repeat: repeat-x;

    Here's an example image:

    alt text

    Here's HTML code that uses it

    <head><title>Gradient Test</title>
    <style type="text/css">
        th {
         margin: 0;
          <th>One line</th>
          <th>Three<br>lines<br>of text</th>

    It will repeat, but only within one direction. Usually a gradient can be safely repeated within one direction, there is no need to stretch it.

  • First of all, I'm assuming you're using CSS to place this background image. You probably need to clarify that part of your answer.

    I don't believe there is a css function that you can use to make your background image stretch. As Mecki says, you can use background-repeat to tile the image horizontally, but that's not going to deal with the header expanding beyond the height of your original tile.

    The simplest way to deal with this would be to just make your background big enough to fit a couple of lines or more.

    So if you make the background say 40px tall or perhaps slightly larger, your not going to add a huge amount in terms of file size, but then you have a more flexible design.

    In general as far as layout and graphics go, it's always best to build in a bit of flexibility, to cope with browser inconsistencies and different user needs.

  • Hey Shivanand,

    The problem you have here is your background is repeating, Mecki's comment is correct and should fix your problem, background images will always repeat unless you state which way it should repeat, if at all.

    Here's a link to all the different CSS background properties that may help you out a little:

  • Alternatively you can set the background colour of the container to the same colour as the last line in the gradient. This way the end of the gradient image will be invisible.

    Shivanand : That was really helpful. Thanks a lot!!
  • Gradient Test th { color:brown; background-image:url(; background-repeat:repeat; margin: 0; } One line Three
    of text Data Data

Define the content-type of an element together with an enumerable attribute

I am having trouble defining the content-type of an element ("phonenumber") whilst at the same time defining a property ("location") with enumeration restrictions.

Here's where I'm stuck:

<xs:element name="phonenumbers">
        <xs:sequence maxOccurs="unbounded">
            <xs:element name="phonenumber">
                Try #1:
                Define the type of the attribute "location" and the
                content-type of the element "phonenumber". But without
                enumeration restrictions on "location".

                        <xs:extension base="xs:integer">
                            <xs:attribute name="location" type="xs:string"/>                                                        

                Try #2:
                Enumerables in attribute "location" with no content-type
                of the element "phonenumber", thus being unable to put
                anything in it.

                    <xs:attribute name="location">
                            <xs:restriction base="xs:string">
                                <xs:enumeration value="Home"/>
                                <xs:enumeration value="Work"/>
                                <xs:enumeration value="Mobile"/>

From stackoverflow
  • What about

    <xs:element name="phonenumbers">
          <xs:element name="phonenumber" minOccurs="0" maxOccurs="unbounded">
                <xs:extension base="xs:integer">
                  <xs:attribute name="location" use="required">
                      <xs:restriction base="xs:string">
                        <xs:enumeration value="Home"/>
                        <xs:enumeration value="Work"/>
                        <xs:enumeration value="Mobile"/>

Can you use the DataContractSerializer outside of WCF?

From the reading I've done I'm under the impression the DataContractSerializer handles versionong issues by, if members in the request are not there it will set the default value, and if addional members are in the request but not in the definition the serializer will simply ignores these fields and not process them.

Firstly, is this assumption correct?

Secondly, could you use this DataContractSerializer instead of the XMLSerializer so you can add this versioning ability to old asmx web services? Basically, if you add new members to your web service schema request you won't need to send to every client? When you receive the request from the client you can Deserialize using the DataContractSerializer into your object.

Hope this makes sense

From stackoverflow
  • You can use the DataContractSerializer outside of WCF to manually deserialize and serialize object graphs. However, you cannot tell ASMX to use the serializer. You are much better of just replacing your ASMX services with WCF services.

  • I have used the DataContract Serializer to import xml files, it works fine.