答:
Assuming these decisions have passed the "use the right tools for the job" stage, and you're genuinely faced with a situation where there are equally useful projects with equally useful tools for each that the developer knows, my thoughts:

I have rarely, if ever, found myself benefitting from working in two entirely different mindsets at the same time. Some reasons I dislike it:

Different assumptions about the final application. It's hard to switch your mindset in between two entirely different setups. To use an extreme example, I find it irritating to be programming for something that's going to go on a cluster one day, and then something that needs to run in an extremely resource poor environment.

Tool familiarity. Even if you're intimately familiar with both coding environments, switching back and forth takes some work. Where's the button to do X in this particular IDE? Does this language start indexing at 0 or 1?

Consistency between projects. Your question actually assumes 4 projects the developer could split their time on, two sets of two similar projects. Presumably, those other projects will get picked up by someone else. It's probably better to have all the X projects follow Programmer 1's style and the Y projects follow Programmer 2's style (assuming they're not spaghetti code, well documented, etc.) than have a weird blend where when you need to work with X, you also need to figure out if it was Bob or Amy who coded this one.

Lets say, as Joonas suggests, that you chose poorly. First, it's equally probable given no information that your choice takes off, so arguably its a wash. But even if you do have the ones you decided to go with collapse, it's probably better to migrate from the new to old platform/system/whatever at the same time - again, using consistent style, than have them ported over by two different teams.

Basically, I vastly prefer to focus on one "type" of project at a time. Put on my "R" or "SAS" or "Python" hat until that project is done, then out-and-out switch, rather than bouncing between them.


问:
Can you recommend a good commit message template / guidelines to enforce in the company?
In Git it's possible to set and enforce a good commit template.

Can you recommend (preferably with argumentation) a good commit template / guidelines to enforce in the company?

答:
I use

```<code>[Abc]: Message.
</code>```

With Add, Mod(ify), Ref(actoring), Fix, Rem(ove) and Rea(dability) then it's easy to extract logfile.

Example :

```<code>Add: New function to rule the world.
Mod: Add women factor in Domination.ruleTheWorld().
Ref: Extract empathy stuff to an abstract class.
Fix: RUL-42 or #42 Starvation need to be initialised before Energy to avoid the nullpointer in People.
Rem: freeSpeech is not used anymore.
Rea: Removed old TODO and extra space in header.
</code>```

If I have more than a line, I sort them with most important first.

ContentLicense: CC BY-SA 2.5

Body:
I use

[Abc]: Message.

With Add, Mod(ify), Ref(actoring), Fix, Rem(ove) and Rea(dability) then it's easy to extract logfile.

Example :

Add: New function to rule the world.
Mod: Add women factor in Domination.ruleTheWorld().
Ref: Extract empathy stuff to an abstract class.
Fix: RUL-42 or #42 Starvation need to be initialised before Energy to avoid the nullpointer in People.
Rem: freeSpeech is not used anymore.
Rea: Removed old TODO and extra space in header.

If I have more than a line, I sort them with most important first.

ContentLicense: CC BY-SA 3.0


问:
Maintaining a list of nodes with challenging requirements
This is a question regarding the design of a collection of ordered nodes which have some requirements that I am struggling to satisfy.

In the problem area that I am dealing with we have routes which are an ordered collection of nodes.  A route will be between 1000 and 25000 nodes.  A node itself is a complex object.

I need to be able to persist the nodes, ideally to a relational database (as the wider application is currently delivered using an architecture that uses a relational database for persistence).  I have two separate requirements which present a difficultly in how to model the data.

I need to be able to insert nodes (or pointers to nodes) into the middle of the list and reorganise the list on the fly.

I need to be able to retrieve the list in it's correct sequential order with both an efficient index and the ability to random access.

The only way I think that I can satisfy the first requirement is to model the data as a linked list where every node points to the next node in the list, which would allow the list to be edited and reorganised on the fly.

The only way I think that I can satisfy the second requirement would be to sequentially order the list so each node has a reference to it's position in the list and order/access the list by the position.

Is there any other method that I could use that can satisfy the two requirements or am I stuck with building a hybrid that employs both methods at various times depending on operational context and that keeps the two referencing types in synch?

答: I would have a look at Boost.graph for dealing with this.  It may seem like overkill at first sight but in the long run you should see more and more benefits. </p>


问:
What frequency of updates is acceptable for a mobile application?
It's possible to publish daily updates for your application on Google's Android Market, but I have an assumption that users don't like to get frequent updates. How can I determine when I should publish updates? Is there an optimum interval to balance between delivering new features and bug fixes while not upsetting my user base?</p>

答:
While there can't some general best frequency for updates, here are some factors that you should look at when making your decision:

Severity of the update. Fixes for critical bugs and security vulnerabilities should of course be pushed out as soon as possible. But if you only have minor changes, you might want to wait until you collected a few of those.

User expectations. If the users expect updates bringing major enhancements, you might not want to push the same kind of update just to fix a typo. :-)

Ease of applying the update. If the update applies itself in the background without needing any user interaction, I doubt anybody would mind frequent updates. If OTOH applying an update requires several interaction steps by the user, thus interrupting his workflow, frequent updates are quite annoying. E.g. almost every time I use NeoOffice, it tells me there is a new version available. But I would have to download and install it manually, taking me away from my original task. So I rarely updated, but was still annoyed every time.

Likelihood to break something else with the update. If there are external plugins/extensions/whatever depending on you application, they should be aware and be able to depend on your update schedule. They also should have enough time to adjust to the changes you made before the update is applied. E.g. when Firefox recently changed to a more rapid update cycle, it broke many of the less-maintained extensions, because the developers couldn't keep up with the rapidly changing version numbers.

Dependence on external factors/libraries/APIs/.... If the update depends on changes of external libraries, APIs, or (as Manfred Moser said) a server side application, you'll have to wait until those are finished.


问:
Is Groovy going away?
I am sure this question has been asked many times. However, I like to ask it again with the intention of what is the future of these languages.

I was first introduced to Groovy and really liked it. I felt the syntax was simpler and it was much closer to Java and I was able to quickly learn Grails.

Then there was Scala, and the web frame work Lift. I am still learning Scala and I find the syntax very difficult at times.

However, I still wonder what is the future of Groovy. When the author of Groovy says he would have never created groovy if he knew about Scala, then it makes me wonder if there is a future at all. Of course Groovy has came a long way and Grails is used today by many large companies.

If one was to look at Grails vs Lift today, then Grails would be clear winner. More companies are using it.  But given everything I have said so far, I am interested to know if one should invest in Groovy? Is Groovy going away and Scala the better choice? If the CEO of BMW says he drives a Mercedes then one would wonder why shouldn't we all drive Mercedes too, right?

(I understand if this question is really broad and might be closed. I hope to make it an open Wiki for others though.)

答:
Groovy is a very nice and underestimated (even by it's own creator, as you've mentioned) language.
As for me, it's role in Java ecosystem is like Lua's role in C/C++ world ecosystem. Yes, it's not that fast but nevertheless.

I'll be very sad if groovy will die, but this roadmap actually tells us that it's not that bad.

Actually, Groovy is very nice, neat, expressive language.
As for Scala, I believe that Groovy and Scala are just in different niches.

Title: Is Groovy going away?


答:
A hybrid in form of linked arrays sounds like a compromise between the two structures. You still fast index access, relatively low overhead with random insertions and really low when inserting in batches.

Wikipedia names this an unrolled linked list

Title: Maintaining a list of nodes with challenging requirements

Body:
This is a question regarding the design of a collection of ordered nodes which have some requirements that I am struggling to satisfy.

In the problem area that I am dealing with we have routes which are an ordered collection of nodes.  A route will be between 1000 and 25000 nodes.  A node itself is a complex object.

I need to be able to persist the nodes, ideally to a relational database (as the wider application is currently delivered using an architecture that uses a relational database for persistence).  I have two separate requirements which present a difficultly in how to model the data.

I need to be able to insert nodes (or pointers to nodes) into the middle of the list and reorganise the list on the fly.

I need to be able to retrieve the list in it's correct sequential order with both an efficient index and the ability to random access.

The only way I think that I can satisfy the first requirement is to model the data as a linked list where every node points to the next node in the list, which would allow the list to be edited and reorganised on the fly.

The only way I think that I can satisfy the second requirement would be to sequentially order the list so each node has a reference to it's position in the list and order/access the list by the position.

Is there any other method that I could use that can satisfy the two requirements or am I stuck with building a hybrid that employs both methods at various times depending on operational context and that keeps the two referencing types in synch?


问:
Recommended ways for getting a good grasp of inherited software
So you've inherited a large codebase that you need to make substantial changes to and you wish to get a pretty complete understanding of the software before starting.

Would you diagram it?

If so, which tool do find most suited for a large codebase?

Ideally I'd want expandable nodes representing major concepts in the flow that could be drilled down into for a sub-concepts, and sub-sub-concepts.

Preferably UML based, but not essential.

Are there decent automatic source diagramming tools, in particular, PHP->UML?

答:
You can not really reverse engineer PHP code to UML.
Reverse engineering is usually done from C,C++, C# or Java to UML.

I had in the past inherited of a huge java code project only including java note and a little printed documentation. We have never been able to discover everything because no previous team was still working in the company. This is exactly what should not be done !!

I am now working as a consultant and help companies to put in place agile processes. What I use is UML class diagram only because easy to understand by all the team and also because incremental. I mean that a code change is immediately updated in the UML model. I can trace model change using the local history. If all the developers leave the company it will always be possible to quickly refactor the project because the UML class diagram is very very detailled. We have one or more diagram per packages. Each important method is explained not only in the code but also with class and sequence diagrams. etc..... I fully understand that model driven is not wanted by developers because they feel they can be replaced by other offshore teams. Having said that the managers should always be in control of the project and not depending on code manipulation.

This is my penny for today but I still consider that developers should be protected and not used as meat by companies. The problem is the level of education and training investment of the team. A developer should think and not just code. He/she should also be able to make advance architecture? Finally if he/she leaves the company it should be possible to immediately restore and refactor existing projects.

OwnerDisplayName: stebbo


答:
It is possible to reverse engineer PHP code to UML (i.e. Class Diagrams). But usually you can't get as much information as from e.g. Java code. In PHP classes member variables commonly have no type in the definition (even though it is possible with recent PHP versions). So a static analysis can't tell which other classes are referenced (even for a developer it is quite time consuming to tell). So the diagrams you are getting "off the shelf" are showing very little dependencies.

Our company is doing reverse engineering with UML Lab which allows to add project specific templates and rules for analyzing a software. You can try it yourself (with the 30-day trial). And the support team is really responsive ;)

Generally a good IDE (with or without UML) helps a lot in understanding PHP software. I would recommend to at least use Eclipse PDT (Open Source) or the Zend IDE (commercial) to get a grasp of the software internals. You can then draw Diagrams of the Software yourself and/or improve the generated diagrams step by step.

Title: Recommended ways for getting a good grasp of inherited software

Body:
So you've inherited a large codebase that you need to make substantial changes to and you wish to get a pretty complete understanding of the software before starting.

Would you diagram it?

If so, which tool do find most suited for a large codebase?

Ideally I'd want expandable nodes representing major concepts in the flow that could be drilled down into for a sub-concepts, and sub-sub-concepts.

Preferably UML based, but not essential.

Are there decent automatic source diagramming tools, in particular, PHP->UML?

OwnerDisplayName: Christian


答:
Enterprise Architect from Sparx Systems can forward- and reverse-engineer PHP, although I haven't used this myself.

As to diagramming, my answer is yes - and no.

I would not (do not) use UML to reverse-engineer code bases. Reverse-engineering tools tend to give you only the easy bits (static structures), and even when they do try to provide you with dynamic aspects these are usually incomplete.

But more to the point, I think a UML representation of the source is pointless. Source code is far easier to read; any decent editor will provide syntax highlighting and block folding, and don't forget the significance of the non-source language files (eg Makefiles, IDE project definitions, etc), which UML reverse-engineerers most likely won't understand.

I use UML to document design, especially runtime and deployment aspects: what programs are built and how do they interact? Which ports does the server open? What threading model is used? How is each program configured? And so on. But I only very rarely refer to any source entities in any models.

OwnerDisplayName: Uffe


答:
You're very optimistic. If you code base does not already have proper documentation and isn't so easy to read, I doubt that it has an organized, structured hierarchy. So UML might just make everything seem like a big mess (which it might be).

If you want to get to grips with that code base (or any new other code base), I recommend reading the book http://www.amazon.com/Code-Reading-Open-Source-Perspective/dp/0201799405


问:
What does backslash "\" escape character really escape?
What does the backslash really escape?

It's used as an escaping character.  But I always wonder what's escaping, or what's being escaped from.

I know "\n" designates a new line. But what where does the escaping come in? Why is it called that?

答:
:))

It is a term related to that of an escape sequence and an Esc (escape) key.

The character itself isn't "running away" from any other character. One might say the character following the escape character (say, \n from your example) escapes the fate of being used as an ordinary n in some application, and is used instead as a newline.


答:
The backslash is used as a marker character to tell the compiler/interpreter that the next character has some special meaning. What that next character means is up to the implementation. For example C-style languages use \n to mean newline and \t to mean tab.

The use of the word "escape" really means to temporarily escape out of parsing the text and into a another mode where the subsequent character is treated differently.

Title: What does backslash "\" escape character really escape?

Body:
What does the backslash really escape?

It's used as an escaping character.  But I always wonder what's escaping, or what's being escaped from.

I know "\n" designates a new line. But what where does the escaping come in? Why is it called that?


问:
In-process SOA?
Can DI/IoC be used for a simplified, local SOA?

I have been reading up on SOA (examples: here, here and here) and it seems that at first a lot of the attention was at interoperability and enabeling distribution of tasks by using standard message-formats and transfer-protocols (web-services). Later the crux has been to achieve loose coupling: To find principles for partitioning business-logic, manage dependencies and how and when to share data between parts.

Is this a correct description? How is this related to DI/IoC? For a system with low performance requirements would it be a simplification to use DI as a "message broker", and asynchronous events to do "pub/sub" and only break out a service and go across an ESB or such as required by integrations?

答:
SOA (particularly the view championed by Udi Dahan) certainly shares its purpose with DI: decoupling systems. However, although the purpose is the same, and some of the mechanics superficially resemble each other (e.g. programming against contracts), the level of granularity is different.

The most important point in both systems is to be able to vary separate systems independently of each other. However, that ambition has a much more profound impact in SOA because each system may be implemented on different platforms and running on different hardware.

Imagine a 'true' SOA architecture implemented on a uniform platform (Java or .NET or similar). In this case you could conceivably collapse the architecture and run a single-box installation using in-memory message brokers, etc.

However, don't expect the reverse to hold. If you start out by writing an application that uses asynchronous messaging and what would look like a SOA architecture, there's no guarantee that you can subsequently scale it out.

There's a lot of subtle pitfalls that one tends to miss until one actually tries it out. One example is that services share data, but not class. If you don't think very hard about these things, you're likely to make some implicit assumptions about how messages are being passed around.

Title: In-process SOA?


答: Software Engineering Radio covered this topic in Episode 148: Software Archaeology with Dave Thomas (of Pragmatic Programmer fame). The podcast had some insightful ways to get a handle on foreign code bases which included looking at the code in tiny fonts in a full-screen editor, walking the code in a debugger with assertions, and being careful of comments (which may no longer be accurate). I can't recall if he touched on tooling to analyze the source, but his ideas struck me as (well) practical.</p>


答:
Presuming this codebase is sufficiently large, I probably would not diagram it.

If the code is too tangled to grasp already, I'm not sure a maze of boxes and arrows will suddenly bring light to it.  I've found that a UML tool lacks the context to give you the big picture you need to start.  You could spend hours or days trying to understand a portion of the diagram that is truly inconsequential to the whole design, just because it seems like a good place to start.

The first tool I would grab in this situation is exploratory testing.  Treat the system as a black box that you don't understand.  If you're going to make substantial changes, you need to know what outputs are generated from a given set of inputs.  Once you've locked that down you can also use these tests to verify your design moving forward.  Exploratory testing gives you a clear way to divide and conquer your way through the codebase.  Once you have some tests in place you can certainly build UML (or reorganize generated UML) to provide a basis for team understanding.

After getting some idea of the ends of the system, I would move on to code review.  My preference here would be code, but if your team is easily distracted by syntax and style issues you might find generated UML to be more productive.  Regardless if you work from code or generated UML, I find working with a partner with a projector and lots of whiteboards will move you to an understanding faster than staring at the screen alone.


问:
How have you found, refined and maintained your coding style?
Recently, I've been switching between several projects and development environments. The expectations for coding style in each is different.

Now, my question is three part, the first, just of curiosity:

How did you define and find your coding style?

How do you keep augmenting and improving it?

How do you maintain it? (From mental notes, keeping a document, using a tool like StyleCop etc.)

答:
1. How did you define and find your coding style?

I go for adopting an already developed style guide that's largely developed and widely accepted or popularized by a large company/project.

I do it for numerous reasons, but mainly because such style guides can be immediately adopted by developers. A style guide is only worth as much as developers are willing to stick to it.

Examples of such are Python's PEP 8, Android's style guide for Java, jQuery Core style guide or Google's Python style guide.

2. How do you keep augmenting and improving it?

The biggest argument for such style guides is that they were Not Invented Here and Not Invented By Me. It took scores of developers, intimidating lines of code and more time than your company/team would ever be willing to invest into developing and maintaining a style guide.

As for improvements, there's never been a style guide that immediately answers everything you may need to know. But, in most cases the improvements that I've seen being pushed forwards were just a more verbose version of what the style guide already paved out with it's approach to writing code.

In such cases when you run into a block of wierdness, you should paste it into a gist or into some other appropriate code snippet sharing tool with color-syntax support and discuss it somewhere with other developers. Great thing about is that in such instances your not interested in what the code does, but just how the code appears, so you can take that block out of context and discuss how you should go about improving it, comparing it to what's already specified in the style guide as the main starting point for discussions.

3. How do you maintain it?

Well, the great thing is that you'll already have existing documents that are publicly maintained online.

When it comes to code formatting, you can also go the extra mile and provide your team with formatter configurations for their favorite editor, which should take out the crud and guesswork on maintaining tip-top appearances. Actually, I wouldn't call it going out an extra mile, but an integral part of development--there's nothing worse that doing a diff where 90% of code changes was someones check-in of properly formatted/styled code because someone forgot to clean up before they committed a huge new feature.


答: If you are part of a team, you should always adder to the team's standard.  There is a lot to be said to use a generic layout and not your own personal one.  It makes your code easier to read and understand by others which is essential. </p>

Title: How have you found, refined and maintained your coding style?

Body:
Recently, I've been switching between several projects and development environments. The expectations for coding style in each is different.

Now, my question is three part, the first, just of curiosity:

How did you define and find your coding style?

How do you keep augmenting and improving it?

How do you maintain it? (From mental notes, keeping a document, using a tool like StyleCop etc.)


问:
Are operators just "special" methods?
Here's what is meant by operators and methods.

Attempting to keep the questions as simple and open ended as possible, since the question is more about the conceptual nature of operators and methods NOT how a language has decided to implement them.

Proof of Concept: This example in Ruby is more of a proof of concept than anything else. EXAMPLE: In Ruby, "1+2" is equivalent to "1.+(2)", meaning the object "1" implements a method called "+" with object "2" as the method's argument.

答:
First, understand that a "method" is nothing but a function. (Please do not confuse "method" with "method overloading", "method dispatch" etc. which are indeed nice language features.)

Second, understand that an operator is nothing but a function with a funny name and special support from the parser so you can write them pre-, post- or infix.

Hence, it is quite correct to say that operators are "special methods".

Title: Are operators just "special" methods?


问:
What made you contribute to that open source project?
I'm interested in real experience and personal answers not just those standard worn out "benefits of contributing to open source" that we all memorized by heart by now.

I've met many people who contribute to open source project and almost never did this topic come up: why did they contribute to this open source project. So, if you've contributed to an open source project before in any way, can you please pause for a second and try to remember what really made you decide to contribute to that particular project.

Was it a random decision, was it because you were bored, was it because the company you worked for was already using it and you contributed as part of your job, was it because the project was too big you wanted to get contracts, or the project was too small you wanted to build it, or because your prof or co-worker asked you to help with his open source project, or.....

To substantiate your reasons, please mention the project name and rate your involvement (heavy, occasional, light, once).

答: I contributed an extension to a Squirrelmail plugin, because I wanted to use that functionality and it was not already available.</p>


答:
There is one simple rule, which is a convention followed by many (if not all) SCMs and by most tools that work with SCMs :

The first line of a commit message is a short summary, while the rest of the message contains the details.

So, most tools display the first line only, and display the whole message on demand.

A typical misuse of a commit message is a bullet list of changes (only the first bullet will be shown). Another misuse is writing a loooong detailed message on a single line.

So, if there is one thing to enforce, I would say it's the maximum length of the first line.

Title: Can you recommend a good commit message template / guidelines to enforce in the company?

Body:
In Git it's possible to set and enforce a good commit template.

Can you recommend (preferably with argumentation) a good commit template / guidelines to enforce in the company?


答:
You can satisfy both requirements by modeling routes as arrays.  In a RDBMS, you might set up a table like this:

```<code>-- Table "route_steps"
id         NUMERIC   -- ID for this row
route      NUMERIC   -- FK:  Which route?
position   NUMERIC   -- Relative position of this step in the route
node       NUMERIC   -- FK:  Which node?
</code>```

Inserting a step in the route would be done by INSERTing a new row and having a BEFORE trigger increment the position in all rows with a position greater than or equal to that of the new row.  Deletion would be the the opposite: DELETE the row containing the step you want gone and have an AFTER trigger decrement the position of any step in the same route with a greater position than the one just deleted.  Since all of this happens in a transaction, the entire operation becomes atomic.

Random access becomes pulling a row from route_steps by position:

```<code>SELECT node FROM route_steps
  WHERE route = id_of_route_of_interest
  AND position = position_of_interest
</code>```

The entire route can be retrieved in sequence with:

```<code>SELECT position, node FROM route_steps
  WHERE route = id_of_route_of_interest
  ORDER BY position ASC
</code>```

Proper indexing will make both of those operations very fast and will also help the UPDATEs done by the INSERT and DELETE triggers find the rows that need updating.

There are a few integrity issues that you'll need to handle, but once you get more than ankle-deep in this, you'll probably figure out what they are.

Personally, I can't see any upside in a hybrid model.  You'll still have to maintain something resembling an array to speed random access using the methods described above.  With that already in place, there doesn't seem to be much point in carrying out the additional work of maintaining the linked list just because it's efficient.

Body:
You can satisfy both requirements by modeling routes as arrays.  In a RDBMS, you might set up a table like this:

-- Table "route_steps"
id         NUMERIC   -- ID for this row
route      NUMERIC   -- FK:  Which route?
position   NUMERIC   -- Relative position of this step in the route
node       NUMERIC   -- FK:  Which node?

Inserting a step in the route would be done by INSERTing a new row and having a BEFORE trigger increment the position in all rows with a position greater than or equal to that of the new row.  Deletion would be the the opposite: DELETE the row containing the step you want gone and have an AFTER trigger decrement the position of any step in the same route with a greater position than the one just deleted.  Since all of this happens in a transaction, the entire operation becomes atomic.

Random access becomes pulling a row from route_steps by position:

SELECT node FROM route_steps
  WHERE route = id_of_route_of_interest
  AND position = position_of_interest

The entire route can be retrieved in sequence with:

SELECT position, node FROM route_steps
  WHERE route = id_of_route_of_interest
  ORDER BY position ASC

Proper indexing will make both of those operations very fast and will also help the UPDATEs done by the INSERT and DELETE triggers find the rows that need updating.

There are a few integrity issues that you'll need to handle, but once you get more than ankle-deep in this, you'll probably figure out what they are.

Personally, I can't see any upside in a hybrid model.  You'll still have to maintain something resembling an array to speed random access using the methods described above.  With that already in place, there doesn't seem to be much point in carrying out the additional work of maintaining the linked list just because it's efficient.


问:
Multiple projects - similar platforms or as different as possible?
When working on multiple projects simultaneously (for the sake of simplicity let's say half time each on two projects), which is better? Should the two projects

Use the same language? Same/similar frameworks?

Use entirely different languages?

Additionally, is it best if they are target for similar platforms, or different (web v. desktop v. mobile v. utility library for internal use)?

The first responses that come to mind are

They should be similar, and play to the strengths of the developer to help him handle managing both of them

They should be as different as possible to help the developer keep organized

Since I've never done this in a professional setting, I was hoping more experience programmers could shed some light on the best way to go about doing this.

EDIT:

This question is assuming the existence of multiple other projects, each of which is underway (I think some underway and some brand new with no design decisions yet made would be too broad for one question). When choosing between existing projects for a second project, should a developer consider how similar his new project is to his current project, and how should that affect the decision?

答:
That depends on what you want.

If you want to get as much work done as possible - choose similar technologies, to minimize learning time.

If you want to learn new things, choose different technologies, to increase exposure to new ideas and technologies.

So it would depend on context.

If it were a hobby project, I'd probably lean towards option 2, because I like to learn new stuff.

If I were assigning developers to projects in a company, I'd try to find a compromise, because for an employer both points are important: You obviously want your employees to get work done, but you also want them to learn new stuff, so you can move them between projects as required.


问:
Are these signs of a bad developer?
I used to blame changing specifications from clients for code rot, not realising that business models do change and it's my job to develop in an adaptable way. I now see that as a sign of a bad developer (I've changed!).

But now I see other 'whinges' in myself. A few times recently I've found myself saying 'it's like trying to fit a square peg in a round hole', and also I find myself blaming client indecision for a project not progressing.

Are there signs I should look out for where I should change my attitude? Is the client always right, or am I sometimes justified in getting frustrated?

答: Client indecision can be a big problem and if you're not the one who's in charge of managing the client relationship than it may be very difficult to deal with. You could talk to the person who deals with the client and explain calmly that progress cannot happen until the client makes a decision. If you are in charge of the client relationship, you have to tell the client that they need to make a decision before the project can continue. It may not be that your attitude needs an overhaul, just a minute of meditation to calm down. ;)

Title: Are these signs of a bad developer?


答:
I wouldn't say you are bad developer. Being aware of the issues already moves you beyond this definition.

Requirements change. That is a given. A good developer need to take this into account. Many modern programming techniques help coping with that.

Staying true to original spec is not realistic. Also not realistic is changing the requirements all the time.

The client is definitely not always right. It is 'right' more often than we want him/her to be, though (as in, try to accommodate him if he isn't totally off). But when you see him driving the project in the wrong direction, try to advocate for the things you think are right.

There are no hard rules on these things, and even good and experienced developers haven't achieved the perfect 'Zen'. The only wrong approach is not trying to improve on these.

Title: Are these signs of a bad developer?

Body:
I used to blame changing specifications from clients for code rot, not realising that business models do change and it's my job to develop in an adaptable way. I now see that as a sign of a bad developer (I've changed!).

But now I see other 'whinges' in myself. A few times recently I've found myself saying 'it's like trying to fit a square peg in a round hole', and also I find myself blaming client indecision for a project not progressing.

Are there signs I should look out for where I should change my attitude? Is the client always right, or am I sometimes justified in getting frustrated?


答:
First, a client does not know what they want until they see it.  That's part of the appeal of the Agile paradigm's small iterations with heavy client involvement.  Second, don't expect a product to be "complete" when you are code complete.

Microsoft employs a product called 'Watson' (the send feedback message you get when windows blows up) in order to trace problems directly back to a client.  Traceability is a good way to track issues back to the users that experience them.  You can get traceability by asking.  Or, if you have the resources, integrate the functionality into the product(s).  The key is tracking the issues/improvements so they can be addressed.

Finally, sure client's can be fickle.  In such cases, I try to focus on the iceberg secret.

Title: Are these signs of a bad developer?


答:
I generally have the identifier that is in the ticket tracking system I use or a high level overview as the first line.  Then I have line item "bullet" points of the specific change in the commit.  So I could of something like:

```<code>MyVideoGameProject-123 OR Inventory System Improvements
Made inventory GUI drap and drap
Added ability to have multiple bag slots to expand inventory capacity
</code>```

This is the cleanest commit format I like.  It is direct and to the point.  Another reason I do it this way is that if I want to create a change log, I could just take all the commit messages and parse it into a change log very easily.

Body:
I generally have the identifier that is in the ticket tracking system I use or a high level overview as the first line.  Then I have line item "bullet" points of the specific change in the commit.  So I could of something like:

MyVideoGameProject-123 OR Inventory System Improvements
Made inventory GUI drap and drap
Added ability to have multiple bag slots to expand inventory capacity

This is the cleanest commit format I like.  It is direct and to the point.  Another reason I do it this way is that if I want to create a change log, I could just take all the commit messages and parse it into a change log very easily.


答:
Changing requirements are a tough fact of life; but code rot is not caused by that.

Code rot happens when there's some parts of your code that you don't exercise frequently; so when you do some changes that "shouldn't affect anything else", you might introduce bugs.  In other words, code that doesn't see daylight slowly decompose and you can't say when it stopped working.

Yes, it's your fault and not your user's.

The real solution? test all your code frequently.  Of course, the best way is to have automated tests with good coverage.

Title: Are these signs of a bad developer?


答: It's bad requirement management or bad analyzing. Your business analyst (if you have one) or whoever gets the requirements needs to sit with the client and try to get all the requirements, even the ones the client may not think of. Clients usually don't know everything that they want, a great business analyst will help them figure it all out.</p>

Title: Are these signs of a bad developer?


答:
Javier makes a good point that changing requirements are a tough fact of life.  I too get frustrated by these situations as too often I find myself working on a product where the developer has to make decisions.  My opinion used to be "Why can't management figure this out with the client?", or "Why did we begin this project if the client doesn't know what they wanted?", "It's so much headache when they change so late in the development".

Simple fact: this will always happen, not just in programming / software development but in every walk of life.  The world would simply be a very boring and very different place if people never changed their mind, never adapted, never addressed change.  People have a tendency to look at what they're given, and improve it.  Do you not do the same thing with your code?  If I have a block of code which I'm not happy with (it's inefficient, messy), I will improve it.  (Does the operating system complain at me?  ...sometimes, if I'm using a certain unnamed OS, but generally not)

As programmers we need to grab opportunities to improve things, and not get depressed or annoyed by them.  Take the opportunity to talk to people, improve your style, improve your work ethics, approach things with an open mind, push yourself to be better than you were yesterday.  Move forward in your career and don't settle too easily.

I understand that not everybody will agree with this answer but I think it's important that the answers to this question cover a wider perspective.

Title: Are these signs of a bad developer?


答:
There are cases where it IS the client. But that's your problem, too

There are cases where it is the developer, and there are cases, where it is the customer. But, usually they're both your problem, so an attitude of blaming oneself tends to be more successful, because it errs on the side of problem solving instead of helpless finger pointing. Therefore, you'll often find it in more experienced developers.

An even better attitude is IMHO to look at it without blame: "it's the customers fault I have lousy code, because he always changes requirements" then becomes "this customer is figuring out what he wants, so feedback, rapid prototyping and flexibility is more important than completeness, robustness and speed".

Kind of a Zen-mind: don't judge it, just see it like it is.

Title: Are these signs of a bad developer?


问:
Good practice on Visual Studio Solutions
Hopefully a relativity simple question. I'm starting work on a new internal project to create tractability of repaired devices within the buildings.

The database is stored remotely on a webserver, and will be accessed via web API (JSON output) and protected with OAuth. The front end GUI is being done in WPF, and the business code in C#.

From this, I see the different layers Presentation/Application/Datastore. There will be code for managing all the authenticated calls to the API, class to represent entities (business objects), classes to construct the entities (business objects), parts for WPF GUI, parts of the WPF viewmodels, and so on.

Is it best to create this in a single project, or split them into individual projects?

In my heart I say it should be multiple projects. I have done it both ways previously, and found testing to be easier with a single project solution, however with multiple projects then recursive dependencies can crop up. Especially when classes have interfaces to make it easier to test, I've found things can become awkward.

答: I've always used a single solution if I'm working on those different layers, or if there is tight coupling with them. I want to hit F5 and have all the projects get rebuilt if needed. I don't think there is a "right" way to do it.</p>


答:
I've seen the best results with one project per layer, plus a testing project per layer.  I have seen few applications that cannot be accomplished in 10 or fewer projects in the solution, where the solution encompasses everything.

Don't fall into the trap of using projects where you really want namespacing.  Tons of projects adds nothing but overhead for no gain.

Title: Good practice on Visual Studio Solutions

Body:
Hopefully a relativity simple question. I'm starting work on a new internal project to create tractability of repaired devices within the buildings.

The database is stored remotely on a webserver, and will be accessed via web API (JSON output) and protected with OAuth. The front end GUI is being done in WPF, and the business code in C#.

From this, I see the different layers Presentation/Application/Datastore. There will be code for managing all the authenticated calls to the API, class to represent entities (business objects), classes to construct the entities (business objects), parts for WPF GUI, parts of the WPF viewmodels, and so on.

Is it best to create this in a single project, or split them into individual projects?

In my heart I say it should be multiple projects. I have done it both ways previously, and found testing to be easier with a single project solution, however with multiple projects then recursive dependencies can crop up. Especially when classes have interfaces to make it easier to test, I've found things can become awkward.


问:
What is the user-experience best practice for an alternative to popup windows?
I'm still new to web design/development. I'm working on a data entry form for an internal system at work. On the form, the user can select an office from a list queried from a database. (The backend for this is PHP and MySQL, if you're curious.)

I would like to add the functionality to allow the user to add an office to the list, among other things, with minimal invasiveness. I don't want to use a popup window since the default behavior for company browsers is to block popups. I've seen this, which shows you how to create an alert alternative in place of a new window. To me that seems like basically the same thing, and not really an improvement except that it would keep the browser from putting a kibosh on the new form.

I think it might also be good just to keep the popup/alert functionality out of the picture altogether and opt for a new undisplayed
 that is triggered by a button or doubleclick, autc. and closed by okay or cancel.

Like I said, I'm still new to web design/development, and I'm wondering what the currently accepted best practice is for accomplishing this task with the best possible user experience.

Update: the real question is "Is there a current best practice for accomplishing this task with the best possible user experience?" The answer may be "no, there are many options and none are more prevalent." What I'm looking for is either that, or "yes, the currently accepted best practice for user-experience in this case is X."

答:
On the form, the user can select an office from a list queried from a
  database

Just use a Combo Box.


答:
The cliche answer for "how do I do this with Javascript" is always jQuery.  I'm immensely happy with its .dialog call:

```<code><div id="popup"><!-- all your markup for the dialog goes here --></div>

$("#popup").dialog ({
    autoOpen: false,
    buttons: {
        "Ok" : function() { alert("ok was clicked"); }
        "Cancel" : function() { alert("cancel was clicked"); $(this).dialog("close"); }
    },
    modal: true
});
</code>```

http://jqueryui.com/demos/dialog/#modal

Title: What is the user-experience best practice for an alternative to popup windows?

Body:
I'm still new to web design/development. I'm working on a data entry form for an internal system at work. On the form, the user can select an office from a list queried from a database. (The backend for this is PHP and MySQL, if you're curious.)

I would like to add the functionality to allow the user to add an office to the list, among other things, with minimal invasiveness. I don't want to use a popup window since the default behavior for company browsers is to block popups. I've seen this, which shows you how to create an alert alternative in place of a new window. To me that seems like basically the same thing, and not really an improvement except that it would keep the browser from putting a kibosh on the new form.

I think it might also be good just to keep the popup/alert functionality out of the picture altogether and opt for a new undisplayed
 that is triggered by a button or doubleclick, autc. and closed by okay or cancel.

Like I said, I'm still new to web design/development, and I'm wondering what the currently accepted best practice is for accomplishing this task with the best possible user experience.

Update: the real question is "Is there a current best practice for accomplishing this task with the best possible user experience?" The answer may be "no, there are many options and none are more prevalent." What I'm looking for is either that, or "yes, the currently accepted best practice for user-experience in this case is X."

Body:
The cliche answer for "how do I do this with Javascript" is always jQuery.  I'm immensely happy with its .dialog call:

<div id="popup"><!-- all your markup for the dialog goes here --></div>

$("#popup").dialog ({
    autoOpen: false,
    buttons: {
        "Ok" : function() { alert("ok was clicked"); }
        "Cancel" : function() { alert("cancel was clicked"); $(this).dialog("close"); }
    },
    modal: true
});

http://jqueryui.com/demos/dialog/#modal


答:
For me, 4* is the magic number. One project for each layer, and one project which defines all the interfaces/DTO's needed to communicate between them.

*7 if you count unit tests


答:
There are many possibilities here:
You could for example:
* use fancybox, for popup-like looking functionality
* when user clicks 'add' you could load a new form, inject it to current page, and scroll to it.
* etc

What I personally would do, is look at the site as it is now. Is similar functionality already present? Can you use it? Does your new solution fit into the current gui?

Even the most usable solution will look bad, if it does not fit with the rest of the site. Your users are familiar with the current gui, if you add something new, you will force them to learn a new thing (that will take a lot of time, and you will get many 'bugreports' about it).


答: IMHO seperate is almost always better. I almost always seperate out my data layer unless the project is 100% trivial. The reason is because the data layer tends to get passed around the most often. Rarely will you hook up a GUI to multiple data layers and expect it to function well. The much more common scenario is that you have a single data layer, and you want it to be distributed out across multiple GUIs (ASP.Net, WPF, and a Silverlight app for example). It is awesome when you can just build the data layer project and put that dll in as a reference in the next GUI you build.


答: Its personal taste, the most important thing is to be consistent. I personally have a seprate project for each layer of the application so the separation is obvious.


答:
It depends on the size of the project

Here's the guidelines I tend to use

A small project, with a handful of pages or less, I almost always keep to a single project.

If the small project's Data Access layer is large or complex, I might separate that out into it's own layer, but otherwise it just sits in its own folder.

If the project is bigger, I'll almost always have a separate project for the DAL, and any further splitting depends on where the boundaries between the application's functionality lies.

If the application has multiple purposes, each with it's own views, viewmodels, etc, then I'll usually separate each piece into it's own area. If each section is small, I separate them by a Folder. If each section is large, I'll separate them by a project.

If I have multiple projects that need to reference the same set of objects (ViewModelBase, RelayCommand, etc), I'll create a project just for the shared infrastructure objects.

If I have a large amount of shared custom styles/templates/resources, I'll create a project just for those.

As a side note, I made a mistake with my first large WPF project and separated them by putting Models in one project, Views in another, and ViewModels in a third. I can tell you now that's not the way to go, since maintenance becomes a nightmare :)


问:
Would you fork an open source project because it's "poorly managed"
If you know of an open source project whose organizer

has gotten really busy that he doesn't maintain it that much

and he's the type of guy that doesn't accept contributions until a few months later (busy I guess) if at all

and the project is starting to flounder

would you fork this project, give it a new name, and continue working hard on it and build a new community around it that's more encouraging to code contributions? Basically a better managed project since the concern now is bad management.

答: I would fork it and do what I needed to do. If that attracted other people, keen to contribute, so be it. I wouldn't go out of my way to try lure people away. That's too much like politicking (for my taste).</p>


问:
Is it possible to access .NET APIs with JRuby?
I know that JRuby can access COM APIs, but can it interface with .NET?</p>

答: You might be able to use Mainsoft for Java EE alias Grasshopper. This article gives a wide level overview. It appears to be free to develop in and run.</p>


答:
It's an escape from the parsing context, that is demanding (what a villain) n to be interpreted as n instead of as a newline.

The most interesting distinction about it is that an escape doesn't
switch parsing context the way a quote character " (or many other
symbols) would do , requiring another " (or some other symbol) to
get back to the former context. They just take a little diversion but get
back on the road ASAP.

Yet no one talks anymore about parsing contexts, as much as no one seems to write parsers anymore, since the advent of xml and json. Some problems stop being mainstream, go into a niche and weird niche concepts like that remain lingering around.

ContentLicense: CC BY-SA 4.0


问:
What is the definition of Time on Task?
Microsoft Guru Eric Brechner discusses measuring "time on task" in his book "Hard Code".  The discussion comes up during a section on Agile - Scrum.  My guess is that it means "time spent to complete task X", but then he goes on to discuss time on task in terms of percentages by team.  So I don't know how to make this logical leap.

In the Microsoft context, what exactly is "time on task"?

First

The daily stand-up meetings in Scrum are highly organized and collect
  useful data.  The team organizer (Scrum Master) simply asks all the
  team members what they accomplished since yesterday (and how long it
  took) [...]

Then

Tracking how long it took is my team's small contribution to Scrum at
  Microsoft. By adding this information to the burn-down data (how much
  is left to do), you can produce fantastic cumulative flow diagrams,
  measure time on task and work in progress, and better estimate team
  capacity.  Typical time on task is around 42% for production teams;
  30% for teams focused on communication--like mine--and as much as 60%
  for co-located feature teams.

答: I think of time-on-task as time I spend directly working on the task. If it doesn't directly advance the state of the project, it's not time-on-task.</p>

Title: What is the definition of Time on Task?


答:
I'm making the assumption that Time on task is Microsofts version of the what we call focus factor, I don't have a reference to confirm, but based on your information I believe it is.

Basically there's no such thing as the perfect man day so often used in estimates. the reality is you'll end up doing any number of other things in your day, conversations, emails,admin and yes, coffee breaks and the occasional off task chat with your team mate.

I picked up the concept from this book which explains it well: http://www.infoq.com/minibooks/scrum-xp-from-the-trenches

You can think of it as a measure of how close to the 'ideal man days' your team is actually achieving. It allows you to understand the true 'velocity' of your team. 75% is considered very good.

Title: What is the definition of Time on Task?

Body:
Microsoft Guru Eric Brechner discusses measuring "time on task" in his book "Hard Code".  The discussion comes up during a section on Agile - Scrum.  My guess is that it means "time spent to complete task X", but then he goes on to discuss time on task in terms of percentages by team.  So I don't know how to make this logical leap.

In the Microsoft context, what exactly is "time on task"?

First

The daily stand-up meetings in Scrum are highly organized and collect
  useful data.  The team organizer (Scrum Master) simply asks all the
  team members what they accomplished since yesterday (and how long it
  took) [...]

Then

Tracking how long it took is my team's small contribution to Scrum at
  Microsoft. By adding this information to the burn-down data (how much
  is left to do), you can produce fantastic cumulative flow diagrams,
  measure time on task and work in progress, and better estimate team
  capacity.  Typical time on task is around 42% for production teams;
  30% for teams focused on communication--like mine--and as much as 60%
  for co-located feature teams.


答:
I contributed to an open source project that would have faded away had I not contributed. I'm happy to say that because I did contribute it's still around and has flourished a little more than anyone expected.

When I switched from Windows to a Mac, my favourite IM client wasn't available. There was a small project started to create one.

It got into early alpha stages, was very buggy and crashy and eventually the author abandoned it. There were quite a few people using it at the time, and each time the IM service updated it's protocol, the client would get worse.

I started writing some fixes for it and before I knew it I had become it's developer. As it turned out, a couple of forks turned up, and the original project died back a little, yet I helped contribute to some of the forks too. The joys of open source!

Right now, an iPhone app I am actively working on is based on one of the forks that popped up for the IM protocol library. It's amazing how open source products can evolve and come full circle sometimes :)

Title: What made you contribute to that open source project?

Body:
I'm interested in real experience and personal answers not just those standard worn out "benefits of contributing to open source" that we all memorized by heart by now.

I've met many people who contribute to open source project and almost never did this topic come up: why did they contribute to this open source project. So, if you've contributed to an open source project before in any way, can you please pause for a second and try to remember what really made you decide to contribute to that particular project.

Was it a random decision, was it because you were bored, was it because the company you worked for was already using it and you contributed as part of your job, was it because the project was too big you wanted to get contracts, or the project was too small you wanted to build it, or because your prof or co-worker asked you to help with his open source project, or.....

To substantiate your reasons, please mention the project name and rate your involvement (heavy, occasional, light, once).


问:
How to reach to the advanced level in SQL?
I think I have a good grasp of SQL and the most features it has, but sometimes when I've done some more advanced Reporting Services a fellow developer has helped me with some stuff and when I open some existing procedures in T-SQL I understand that I have some learning to do.
I think I have focused more in later years at application code (C# and javascript mostly) and somehow my SQL skills aren't there where It should be. Because at work the most stuff is very database centric with procedures, so I think I need to get better at SQL.
But when I google around about features and look in books about SQL I know the most stuff, but somehow getting better at SQL ain't so easy any more. Does anybody have any advice how to become an advanced SQL programmer? What books to pick up? By the way I work exclusively with SQL Server. </p>

<p>I've done tons of basic procedures with inserts, updates, selects with joins and group by and so on. But doing bigger problems I've always done a more application-centric approach with arrays and collections, but sometimes (Reporting) there's no choice than do it in SQL and work with temporary tables and so on. I'm tempted to do cursors because then I can loop through everything but that kills database performance (how about looping through a half million rows with a cursor?). </p>

答:
The best bet is to fully grok a good database textbook from cover to cover. Then you apply all you know with sample DB projects.

Basically work really hard at it. Get good at remembering stuff too. Yeah it's all in the reference manuals, etc, but having it handy in your brain cache is super.


答:
Generally, think sets.

Try to avoid OO and procedural code for a while. Forget about the next .net framework if you're serious. I left most non-SQL work behind years ago and never looked back.

Start following a more DB specific site actively like DBA.SE (which has development stuff too), even read the highest scoring answers to see coding techniques in action.

Pick up a book by Joe Celko or Bill Karwin for a theoretical view of sets and databases without overdoing it.

Title: How to reach to the advanced level in SQL?

Body:
I think I have a good grasp of SQL and the most features it has, but sometimes when I've done some more advanced Reporting Services a fellow developer has helped me with some stuff and when I open some existing procedures in T-SQL I understand that I have some learning to do.
I think I have focused more in later years at application code (C# and javascript mostly) and somehow my SQL skills aren't there where It should be. Because at work the most stuff is very database centric with procedures, so I think I need to get better at SQL.
But when I google around about features and look in books about SQL I know the most stuff, but somehow getting better at SQL ain't so easy any more. Does anybody have any advice how to become an advanced SQL programmer? What books to pick up? By the way I work exclusively with SQL Server. </p>

<p>I've done tons of basic procedures with inserts, updates, selects with joins and group by and so on. But doing bigger problems I've always done a more application-centric approach with arrays and collections, but sometimes (Reporting) there's no choice than do it in SQL and work with temporary tables and so on. I'm tempted to do cursors because then I can loop through everything but that kills database performance (how about looping through a half million rows with a cursor?). </p>


问:
Storing stop/start points in a database
Let's say I am storing start and stop points per user into a database table.

For example... let's say in a chat system, a user only needs to see lines 24-293, and 500-512. (Let's say he logged off for the night, and was not present between lines 294-499).

Saving each start and stop point as a discrete row would lead to a huge ballooning table, which isn't exactly ideal. I wouldn't be searching on these points, so indexing is not necessary.

How would I save this kind of information in the database?

I was thinking of saving it in JSON:

```<code>accountID   |   lines
        1   |   [24,293,500,512]
</code>```

Where each odd value denotes a start, and each even value denotes an end. My only worry is that highly active users will be joining and leaving a chat, and would quickly fill up the row if lines was of type VARCHAR.

So perhaps TEXT, or even LONGTEXT.

Am I heading down a path of hurt, or is this a viable method?

Thanks in advance!

答:
First off, database are good and storing lots of rows.  That is something that is ideal for a database.

If you know you will never need to do more with the data, and you can guarantee that the string size has a maximum, then it won't hurt, just cause some extra parsing cpu cycles.  (But don't be surprised at the fact that things aren't always predictable.)

If you find you need the following, you've just created yourself some pain:

overloading the json to include more information because it's easier than maintaining a database schema

finding that you do want to search or sort numbers, or join to other tables

good debugging on the process that inserts, updates and deletes the data

some users hit the edge case of needing so much string data that the field is truncated

At the point that you do decide to switch to table data, you'll need to create a process to parse the string and insert new rows into the new table.  For your current json spec, that shouldn't be too bad to write.  (As long as you didn't overload the json.)

Storing numbers in a database as a string adds an extra level of processing that isn't necessary.  You now have to parse the string.  You'll still need to store the numbers if they are table rows or a string, so size shouldn't really matter.  I wouldn't worry about the number of rows in the database, indexes will do just fine.

Sticking with one format (database) instead of two (database + json) is never a bad idea.

I would create a secondary table for just the start and stop points with an index on account id.  Then you can rely on database features to provide searching, sorting and caching.

```<code>accountID | start | stop
------------------------
        1 |    24 |  293
        1 |   500 |  512
</code>```

Title: Storing stop/start points in a database

Body:
First off, database are good and storing lots of rows.  That is something that is ideal for a database.

If you know you will never need to do more with the data, and you can guarantee that the string size has a maximum, then it won't hurt, just cause some extra parsing cpu cycles.  (But don't be surprised at the fact that things aren't always predictable.)

If you find you need the following, you've just created yourself some pain:

overloading the json to include more information because it's easier than maintaining a database schema

finding that you do want to search or sort numbers, or join to other tables

good debugging on the process that inserts, updates and deletes the data

some users hit the edge case of needing so much string data that the field is truncated

At the point that you do decide to switch to table data, you'll need to create a process to parse the string and insert new rows into the new table.  For your current json spec, that shouldn't be too bad to write.  (As long as you didn't overload the json.)

Storing numbers in a database as a string adds an extra level of processing that isn't necessary.  You now have to parse the string.  You'll still need to store the numbers if they are table rows or a string, so size shouldn't really matter.  I wouldn't worry about the number of rows in the database, indexes will do just fine.

Sticking with one format (database) instead of two (database + json) is never a bad idea.

I would create a secondary table for just the start and stop points with an index on account id.  Then you can rely on database features to provide searching, sorting and caching.

accountID | start | stop
------------------------
        1 |    24 |  293
        1 |   500 |  512


问:
Verification naming confusion
According to Martin Fowler classical article, there are two types of verification: state and behaviour verification. At the same time I often see people telling about implementation vs. behaviour verification. So I guess we speak about pretty same stuff here and "state" in the first classification is "behaviour" in the second; "behaviour" in the first equals to "implementation" in the second.

What I don't like is that "behaviour" word appears in both namings but on contrary sides which causes a lot of confusion.

Which naming do you prefer?

答:
These two approaches use different meanings of the word "behavior".

The first one (behavior vs. state) is based on a design mindset that views programs as a collection of states and transitions between those states. In such a model, "state" is a static thing; if you had a computer that you could freeze or single-step (like those back in the 1970's), then you could stop it at any time and inspect its state (the values currently stored in its register and memory), but to observe its behavior, you need it to run. It is quite common to visualize the dynamic aspects of a (part of a) program as a diagram where boxes represent states, and arrows represent transitions between those states.

The second meaning offsets functional characteristics of the program (what does it do?) against technical details (how did they make it do what it does?). This separation is fairly common; many methodologies split the design phase into functional and technical design parts. In this mindset, the behavior of a program is what it functionally and observably does, from a user's perspective (e.g., when I click this button here, a bunch of dummy text appears above it); the implementation, by contrast, is how it's done (e.g., there's this HTML form with a submit button, and the server-side script reads the POST request fired by that script, calls a web service to generate some lorem ipsum, and inserts it into the form which then gets sent back in the response).

The first meaning is interesting, because deciding what you want to model as state (data) and what you want to follow implicitly through behavior has a huge impact on any software project. Making your data too rigid makes you inflexible to future change; putting too much information in your logic and too little in your data makes for an unmaintainable mess of complex logic.

The second one is important, because it allows you to specify requirements without making any technical decisions (yet). If the functional requirements are unambiguous and clear, you can then verify that the technical design meets the functional requirements, and later, during acceptance testing, you can also verify that the actual product meets the functional requirements (which is far more important than meeting the technical requirements: who cares if you haven't used XML, as long as the thing does what it's supposed to do).

Title: Verification naming confusion


答:
You're trying to denormalise separate facts into a single record, rather than storing them as individual records.

Don't.

You appear to believe that it will be easier and more efficient to do parsing of pseudo-sets yourself than to store them in the normal way. That is possible but unlikely unless you actually tried it out and determined that your database has  problems with the amount of records you would create. But as long as the facts are created by manual clicking activity of users, it is very very unlikely that your database will run out of rows before you run out of processor cycles manipulating the ever-growing strings you would need. Play to the strengths of the components you use. Databases are for storing millions upon millions of rows. Try to outperform them at your peril!

Title: Storing stop/start points in a database

Body:
Let's say I am storing start and stop points per user into a database table.

For example... let's say in a chat system, a user only needs to see lines 24-293, and 500-512. (Let's say he logged off for the night, and was not present between lines 294-499).

Saving each start and stop point as a discrete row would lead to a huge ballooning table, which isn't exactly ideal. I wouldn't be searching on these points, so indexing is not necessary.

How would I save this kind of information in the database?

I was thinking of saving it in JSON:

```<code>accountID   |   lines
        1   |   [24,293,500,512]
</code>```

Where each odd value denotes a start, and each even value denotes an end. My only worry is that highly active users will be joining and leaving a chat, and would quickly fill up the row if lines was of type VARCHAR.

So perhaps TEXT, or even LONGTEXT.

Am I heading down a path of hurt, or is this a viable method?

Thanks in advance!


问:
What's your favourite quote about programming?
What's your favourite quote about programming?

One quote per answer, and please check for duplicates before posting!

答:
A programmer started to cuss

  Because getting to sleep was a fuss

  As he lay there in bed

  Looping 'round in his head

  was: while(!asleep()) sheep++;

Not quite a quote as such, but I little limerick I've always liked.

Source piercings - bash.org/?845468

LastEditorDisplayName: Roger Pate


答:
This why you should always get a Business Requirement Document setup and signed off on before any application goes beyond the prototyping/research phase.

Now, the idea that this document is actually final is faulty, but this should help you get a better idea of what the customer actually wants. And as long as you write your code with maintainability in mind, you can keep your issues to a minimum.

And if you ever need an excuse to fall back on, you can blame any delays on the BRD, that the client signed off on, not including such and such feature, etc.

(Of course, this is just an excuse in case you need it. You should always plan on them changing something)

Title: Are these signs of a bad developer?


答:
Escape sequences have a lot in common with the concept of out-of-band communication:

Also sometimes used to describe what communications people call shift characters, such as the ESC that leads control sequences for many terminals, or the level shift indicators in the old 5-bit Baudot codes.

Let's say you're doing a file transfer over a serial port and you negotiate with the computer on the other end: "OK, here comes the file".  Since in the general case all characters might be valid file characters (if it's an ASCII file) you have some problems:

How do you know where the end of the stream is?

Some schemes use ASCII NUL (zero) to terminate, like strings in some languages, but then you can't have that character in the file.  That's not allowable in some settings, like file transfers.  Zero could be a valid character.

You could send the expected file length first, but what if you need to abort?

Various people throughout the history of computing have implemented lots of different methods to get around this problem.

In the case of literal strings in a programming language, it's a similar problem.  The first quote says "here comes the string - start reading until you get another quote".  Of course, then you have the problem of sending a quote character, so they invented the slash escape sequence.  If you see a slash and then a quote, then that's a literal quote, not the end of the string.  Unfortunately you just swallowed a spider to eat a fly, because now you can't send the literal slash-quote combination.  So, you can escape a slash with another slash.  So slash-slash means slash, slash-quote means quote.  That allowed them to use slash for other unprintable or hard-to-print characters like carriage returns, line feeds, tabs, etc.


问:
Who should be responsible for writing/updating design specifications in an agile team
I work as part of a scrum-like Agile team and a while ago, one thing we identified that the team should do is maintain good set of design documents for our code base.  Because we are agile and do have good amount of discussion and communications, our designs are kept at a high level and are generally used for describing general layout of modules, including main classes and some of their interactions and. We also found them useful for discussion starting points since and also for reminding people that design needs to be considered before you jump into code.

So far, it was expected that everyone will update design specs on as needed basis.  Design leads for each team are responsible for giving people advice on design in general, on what to update in the SDSs and also for reviewing the specs to make sure everything stays consistent.

The issue I'm seeing is that while everyone, especially new members find design specs very helpful when learning new components or even going back to components they haven't touched for a while, most people only update the docs for the sake of updating them (i.e. they are told they must do it and so they do it).  So that we end up with one-liner descriptions which sometimes aren't even full sentences and when I tell them this needs to be updated and filled in, they add more but again, only because they are told.  So now one-liners become 1.5 lines and there's still nothing helpful written down.

Obviously different team member skills/strengths will be different. So the question is, should certain team members on an agile team simply not be responsible for design and be reduced to just a coder? Or should it be design leads role to go back to those team members and make them rewrite the specs as many times as necessary (and this is really becoming painful) until they pick up enough skills to produce what's expected?

My basic guideline that I suggest to everyone: if you were sitting in a meeting or making a presentation about class diagram X, what would you say if your audience needed to know how your code works. Instead, half the time they simply restate what I can already see in the class diagram.  "Class X implements interface Y". That would be entire class description.

Amendment:
I work for a large corporation with a very healthy appetite for outsourcing/contracting. The team I'm on has permanent members, it also has permanent members who are very new to the team (from recent merger).  And we have contractors from India and Poland who will most likely be reassigned to other project after the current release.  So different members have different buy-in at this point. Documentation is definitely important to those of us that have been on the project in the last release and will be on the project in the next release.

答:
I'm not sure if you have read it, but I recommend reading Scott Ambler's article on Agile/Lean Documentation.

The issue I'm seeing is that while everyone, especially new members find design specs very helpful when learning new components or even going back to components they haven't touched for a while, most people only update the docs for the sake of updating them (i.e. they are told they must do it and so they do it).

That seems somewhat contradictory. If the team members actually do find the documentation useful, that should be a motivating factor in keeping them up-to-date. If your development team isn't actively updating the documentation to capture decisions, perhaps some problems need to be addressed. Is the documentation relevant? Does the current format of the document facilitate communication? Are you trying to produce documentation that is too good or too formalized for the purpose?

So the question is, should certain team members on an agile team simply not be responsible for design and be reduced to just a coder? Or should it be design leads role to go back to those team members and make them rewrite the specs as many times as necessary (and this is really becoming painful) until they pick up enough skills to produce what's expected?

Delegating design documentation updates to a single team member, in my opinion, goes against agile. Part of the point of agile is to reduce risk, and you do this by spreading responsibility around. Just like no one owns code, no one individual owns documents either. Rather than have team members rewrite specs, try something like pair programming to teach these people how to write better documentation or institute reviews on produced documents to provide appropriate feedback.


答:
If these are multiple projects at your job or for your own business, its probably better to use a similar stack of technologies to enhance the chance of being able reuse parts of one in the other.

BUT, if one project is for work, and one is a personal project you are doing at home - that is, two completely different venues - then use separate technologies.  Presumably code-reuse in that case is out of the question anyways, since you cant copy your employers code.  By using a different stack you'll be less likely to 'burn' out on one or the other because you wont be looking at it for 12 hours a day.

Title: Multiple projects - similar platforms or as different as possible?

Body:
When working on multiple projects simultaneously (for the sake of simplicity let's say half time each on two projects), which is better? Should the two projects

Use the same language? Same/similar frameworks?

Use entirely different languages?

Additionally, is it best if they are target for similar platforms, or different (web v. desktop v. mobile v. utility library for internal use)?

The first responses that come to mind are

They should be similar, and play to the strengths of the developer to help him handle managing both of them

They should be as different as possible to help the developer keep organized

Since I've never done this in a professional setting, I was hoping more experience programmers could shed some light on the best way to go about doing this.

EDIT:

This question is assuming the existence of multiple other projects, each of which is underway (I think some underway and some brand new with no design decisions yet made would be too broad for one question). When choosing between existing projects for a second project, should a developer consider how similar his new project is to his current project, and how should that affect the decision?


答:
There's a saying one of my professors in college liked to throw around "find the contradiction between what people say is important to them and what they actually do and you'll understand them perfectly".

So the team says they like documentation, but don't actually create it when appropriate? What they value is convenience. It is much easier to read well written documentation than to try and tear in and understand code. It is also a lot easier to ignore updating documentation than to do it. So where ever it is that you keep your list of team values strike out documentation (if you even put it on there) and write convenience big bold letters.

So now when discussing stories and creating tasks, the team will have to address the convenience factors. Is this something that should be written down for the future? Will the value it might give down the road balance out against what it costs now?

Title: Who should be responsible for writing/updating design specifications in an agile team

Body:
I work as part of a scrum-like Agile team and a while ago, one thing we identified that the team should do is maintain good set of design documents for our code base.  Because we are agile and do have good amount of discussion and communications, our designs are kept at a high level and are generally used for describing general layout of modules, including main classes and some of their interactions and. We also found them useful for discussion starting points since and also for reminding people that design needs to be considered before you jump into code.

So far, it was expected that everyone will update design specs on as needed basis.  Design leads for each team are responsible for giving people advice on design in general, on what to update in the SDSs and also for reviewing the specs to make sure everything stays consistent.

The issue I'm seeing is that while everyone, especially new members find design specs very helpful when learning new components or even going back to components they haven't touched for a while, most people only update the docs for the sake of updating them (i.e. they are told they must do it and so they do it).  So that we end up with one-liner descriptions which sometimes aren't even full sentences and when I tell them this needs to be updated and filled in, they add more but again, only because they are told.  So now one-liners become 1.5 lines and there's still nothing helpful written down.

Obviously different team member skills/strengths will be different. So the question is, should certain team members on an agile team simply not be responsible for design and be reduced to just a coder? Or should it be design leads role to go back to those team members and make them rewrite the specs as many times as necessary (and this is really becoming painful) until they pick up enough skills to produce what's expected?

My basic guideline that I suggest to everyone: if you were sitting in a meeting or making a presentation about class diagram X, what would you say if your audience needed to know how your code works. Instead, half the time they simply restate what I can already see in the class diagram.  "Class X implements interface Y". That would be entire class description.

Amendment:
I work for a large corporation with a very healthy appetite for outsourcing/contracting. The team I'm on has permanent members, it also has permanent members who are very new to the team (from recent merger).  And we have contractors from India and Poland who will most likely be reassigned to other project after the current release.  So different members have different buy-in at this point. Documentation is definitely important to those of us that have been on the project in the last release and will be on the project in the next release.


答:
One should start by seeing if the current maintainer would be willing to let you take over. Since the issue is that he his busy, I would expect him to be willing to hand it off. If that works it is better for everyone involved.

If that fails, I'd suggest collecting contributions into a distribution that you maintain without making it a separate project. That way you work within the existing community. The hope is that eventually the maintainer will see the light and accept your offer to take over.

If that fails, fork it. At that point you have gained some visibility and I think you'll attract some of the original community. But at the same time, you have made it clear its not your desire to split the community.

Title: Would you fork an open source project because it's "poorly managed"

Body:
If you know of an open source project whose organizer

has gotten really busy that he doesn't maintain it that much

and he's the type of guy that doesn't accept contributions until a few months later (busy I guess) if at all

and the project is starting to flounder

would you fork this project, give it a new name, and continue working hard on it and build a new community around it that's more encouraging to code contributions? Basically a better managed project since the concern now is bad management.


答:
I believe the way you stated your question already contains the answer.  You're talking about the type of documentation that relates to only one type of work -- designing and implementing software code -- so the people responsible for it should be the ones who carry out this type of work: the software developers.  Agile or not.

I do find a contradiction in your question and resolving it may help.  One one hand you say, " one thing we identified that the team should do", but on the other hand you say the very same team who "identified it" are now so reluctant and sloppy at maintaining these design documentation -- this may indicate that they didn't really buy into it.

I would ask, who identified this documentation activity as a need?  Did the team buy into it?  How exactly did they agree to carry it out?  Revisit this topic and these questions in a retrospective.


问:
The cost of running a Windows App Server
I want to know what is the cost of running a Windows Application Server.

I know the cost of running a Linux server with Java based Application Server is probably zero.

What is the cost of running a windows based server on which all Apps are written in C#? I assume is is just the license cost of a copy of Windows Server.

Is this true? Are there any other hidden cost for hosting with WIndows?

I think with Cloud based hosting, these license costs can be avoided then.

答:
Yes, the only software cost is the OS. Obviously hardware costs vary hugely dependent on requirments (hosting maintenance ect)

Cloud based hosting the provider pays the OS licence. That cost is then passed on to you in the monthly charges. You should only go with cloud hosting if it meets other requirements (scalability low startup cost ect)


答:
The real costs in hosting are:

Power

Bandwidth

People to manage the box

Backups

Hardware and software amortize real, real quick.

Title: The cost of running a Windows App Server

Body:
I want to know what is the cost of running a Windows Application Server.

I know the cost of running a Linux server with Java based Application Server is probably zero.

What is the cost of running a windows based server on which all Apps are written in C#? I assume is is just the license cost of a copy of Windows Server.

Is this true? Are there any other hidden cost for hosting with WIndows?

I think with Cloud based hosting, these license costs can be avoided then.


答:
Yes a windows license costs money, a windows server (required for some kinds of Microsoft software development, e.g. SharePoint) costs more. So does the hardware (but hardware isn't free on linux either).

There are limits to the hosting abilities of windows non-server boxes. Keep this in mind if you need IIS. Also keep in mind that Microsoft offers development versions of many of their products at a greatly reduced cost (don't buy the full edition until you close a sale to justify it).

Do you need an IDE or command line building? Free? Or Paid?

Do you need a database? What kind? Free? SQL Server? Which version of SQL Server?

If you are selling software, MySQL isn't always the best choice. Suddenly, that "free" RDBMS comes with an annual and sky-high fee.

So, to answer your question...are there hidden costs? It depends.


问:
How to learn about graph algorithms and some real world applications?
I've read Franco Moretti's work, but I'm looking for something more technical and perhaps broad in scope, if possible.  Specifically, I want to learn about techniques programmers are using to glean information from complex networks, eg clustering.  I'd also like to know what are some interesting questions/problems when it comes to graphs.

So far I've just skimmed academic papers with very specific applications.  I would appreciate any advice.

Thanks!

答:
Travelling Salesman Problem would be one of the more classic graph problems out there.  List of NP-complete problems has a section on Graph Theory as well as Network Design.

Flow network would be an area of Mathematics around special kinds of graphs that may be of some help though it would help if you could narrow down the question a bit.


问:
Are there any non-blocking web servers for Java?
I was studying about the infrastructure being used by Facebook, as I was developing a website based on social interaction for a university project.

Facebook is using Tornado Web Server as its scalable, non-blocking web server, but it's written for Python. I'm trying to find something similar for Java: what should I be looking at? What are your experiences in non-blocking web servers for Java?

答: You can use ngnix as a proxy in front of a java container. The problem that Tornado and ngnix solves is that the io on the sockets is event driven instead of blocking, which limits your standing connections to something like 10,000. In a java environment you can use ngnix as a reverse proxy/load balancer for one or more java containers and achieve similiar scalability. There are projects like netty from jboss that are starting to address this problem for the java space, but I'm not sure if there are any commercial implementations using it.</p>

OwnerDisplayName: Pinnacle


问:
Practical way to store a "reasonably large" amount of data that hardly ever changes?
Think in terms of pre-computed lookup tables or something.  At what point does it make more sense to use a database instead of hardcoding values in my application?  The values are not going to change, and they're nicely segregated away from maintenance developers.  100 values, 1k, 10k, 100k?  I'm wanting to store about 40k values.  Right now it's a machine-generated switch statement (which VS2010 is unhappy about).

edit:

If anyone is curious, here's how I approached this:  My data was storable in two 100k-element float arrays, so that's what I did.  It took about 20 seconds to generate the data, so I did that once, and serialized it to an embedded resource with a BinaryFormatter.  Unpacking the data takes about 5 milliseconds at application startup, and outperforms the database implementation I was replacing (these hard-coded values were stored there prior) by almost 45,000x.

答:
Personally, I am Ok to store any amount of data, hardcoded into the application, until there is no need to tweak it for one particular deployment or hotfix.

However, storing and accessing data using C# switch statement, is rather bad practice, since in tightly couples data storage and data access model and implies only one method access method (by switch parameter).

I would prefer to store data in a Hashtable or Dictionary, and provide separate classes for retrieving the data, and one time populating  of look-up Dictionaries.

Recently, I've found rather convenient to implement small DSL for specifying business rules ( fluent interface for SiteMap or tax calculator interview question check "calc" method for rules defenition ) and then provide separate object for querying these rules. This technique would apply well for switch case scenario.

One of the nice benefits of such decomposition, is that you can implement a number of Views on your data, without touching XXXk lines blob, that defines that data.


答: A 40k line switch statement is a little questionable.  I assume you still need to perform query operations right?  Have you tried encapsulating the data?  Then use LINQ to perform query operations on the collection to test performance.  Get some concrete times by running unit tests with a timer like StopWatch.  Then, if you think it might just work.  See if performance is acceptable for the users.</p>

Title: Practical way to store a "reasonably large" amount of data that hardly ever changes?

Body:
Think in terms of pre-computed lookup tables or something.  At what point does it make more sense to use a database instead of hardcoding values in my application?  The values are not going to change, and they're nicely segregated away from maintenance developers.  100 values, 1k, 10k, 100k?  I'm wanting to store about 40k values.  Right now it's a machine-generated switch statement (which VS2010 is unhappy about).

edit:

If anyone is curious, here's how I approached this:  My data was storable in two 100k-element float arrays, so that's what I did.  It took about 20 seconds to generate the data, so I did that once, and serialized it to an embedded resource with a BinaryFormatter.  Unpacking the data takes about 5 milliseconds at application startup, and outperforms the database implementation I was replacing (these hard-coded values were stored there prior) by almost 45,000x.


答:
I will go with the "broad side".

Let's go. I will list a couple of books that I'm using.

Graphs, Algorithms, and Optimization (Discrete Mathematics and Its Applications)

Modern Graph Theory

Don't know if you dig python. But I'll list here some interesting stuff:

http://code.google.com/p/python-graph/

Python Algorithms: Mastering Basic Algorithms in the Python Language: you could just glimpse at the graph parts. This book is a "easy-reading" book.

Real world applications:

Mining social data using Facebook Open Graph Protocol

Mining the social web: Introductory book that will show you the tools and how to start mining the social web.

I hope it helps =) cheers!

Title: How to learn about graph algorithms and some real world applications?

Body:
I've read Franco Moretti's work, but I'm looking for something more technical and perhaps broad in scope, if possible.  Specifically, I want to learn about techniques programmers are using to glean information from complex networks, eg clustering.  I'd also like to know what are some interesting questions/problems when it comes to graphs.

So far I've just skimmed academic papers with very specific applications.  I would appreciate any advice.

Thanks!


答:
The key thing here is to make sure your public interface encapsulates your implementation-  but that's not your question and there is no reason to think you haven't.  Beyond that, it's just a question of performance vs grief (and performance differences may well not be worth caring about).  As a practical solution, for the VS 2010 issue, you could always break the case statement up into a hierarchy of case statements - the top level could call one of 10 other methods, each with a case statement of 4000 cases, for example.  You could put each of the 10 into it's own file if you had to.  A little ugly, but you are code generating anyway.

As for the number to switch to a DB -it's just whenever not using a DB becomes a problem.


答:
Netty

Netty is a high performance event-driven network framework that has support for HTTP and other  common protocols. Netty uses non-blocking I/O. But it's pretty low level to use.

Play Framework

Play Framework is a modern web framework for both Java and Scala. It has a very short development cycle - just save your file and update your browser. It's inspired by Ruby on Rails. Play Framework is by default based on Netty (embedded), but it can also be used in a Java Servlet container as a war-file.

I have been using Play Framework in a few months. It's a framework that is easy to use and it has very good performance since it's based on Netty. If you have done some GUI programming e.g. using Swing then you have done event-driven programming before and it's the same principles: Do all long-running processing in a background thread, otherwise your server will be blocked like a GUI is blocked when the thread is used incorrectly.

Title: Are there any non-blocking web servers for Java?

Body:
I was studying about the infrastructure being used by Facebook, as I was developing a website based on social interaction for a university project.

Facebook is using Tornado Web Server as its scalable, non-blocking web server, but it's written for Python. I'm trying to find something similar for Java: what should I be looking at? What are your experiences in non-blocking web servers for Java?


答: You could use something like SQL Compact. Put the data in a table and leave the DB file in the project. Tables are better suited for that amount of data than a switch statement.</p>