问:
Why learn Flash Builder 4 (Flex) when I can just use Flash Professional?
I want to learn Flash Builder 4 (Flex) because I see so many jobs requesting experience with it. I also just like knowing stuff. I am also very interested in focusing on RIA development now.

BUT... can anyone tell me CLEARLY why the heck I would ever use FLEX over Flash Pro? It is a time investment, so is it worth it?

All I read are misguided posts about how Flash Pro is for games and banner ads, and Flex is for programmers and RIAs blah blah... this simply isn't so from my 9 years of contracting experience. I'm 99.9% certain that I can build anything a flex developer can build, but using Flash Pro. I can build powerful AS3-driven apps for the desktop, mobile device, or browser, and I can link to databases with XML and I can import text files and communicate with ColdFusion and everything. The advantage with Flash Pro is that I can also easily and clearly animate transitions and build custom elements that look the way I want/need them to look for my specific client.

Why would I want to use a bunch of pre-built components that drive my file sizes to the moon? Who is happy with a drag-n-drop button? Is Flex just a thing made for programmer people with no artistic inclination? What is the advantage of using it? It takes me back to Visual Basic class. Seems like a pain to have to use multiple tools to import crap from Flash Pro into Flex and yada yada... why when I can do it all nicely in Flash Pro to begin with. Am I clueless, or missing some major piece of the puzzle?

Thanks for any clarity. PS, I couldn't care less about the code editors. It ain't that bad people. They make it out like the thing doesn't even respond to keyboard input or something. Does everything I need it do anyways. Please help out here. If I just don't need to learn it, I don't want to waste the time.

答:
I can relate as a multimedia developer coming from a design environment, although I have a background in programming from years back, so I may be coming at this from a different angle. I started out in Director, back in the early 90s, and fell in love with Lingo, and how it combined the scripting like you see with Flash today (scripts attached to objects and frames) with a more programming-like "compiler" script (the "Movie Script") where all of your functions were defined under event handlers. This appealed to both my "design" side and my "programming" side. As Flash began edging Director out, I just couldn't get into it that much. I felt it was a watered-down version of Director, so I directed my attention toward learning PHP and database administration.

Fast-forward 8 years, and I'm now learning Flash Builder 4.5, and it is absolutely WONDERFUL! First off, I'll mention that FB4.5 and Flash Pro are meant to work TOGETHER. For more on this, check out Lee Brimelow's tutorials (particularly the one on Iso3D) at http://www.gotoandlearn.com/

If you want to get involved with any serious, enterprise-level or web site that's going to need to tie in to a large integration with a corporate site, you're going to need to approach the project from a programming perspective, not an animation perspective. You can do all your magic in Flash Pro, certainly. But once you use Flash to it's full potential as an animation and design program, you can then import that work, in it's entirety, into Flash Builder, and open up a whole new world and ease-of-use when it comes to data integration and adding classes and using Skins and CSS to easily create alternate versions, or more practically, use boilerplate templates to "assembly line" your production.

So I would suggest getting at least the basic version of it (the 60 day trial is plenty of time to check it out), and hitting the Adobe Flash Builder Developer Connection pages, they've got some quick-start tutorials that are great (http://www.adobe.com/devnet/flex.html). If nothing else, think of it this way: Learning the basics and demonstrating this with a simple Flex portfolio page will get you an interview for a Flex developer job. Your killer Flash AS3 work will secure you the position. And your ability to do great graphics/animation AND work directly with the programmers and network people will fast-track you for management. Good luck! ;)

OwnerDisplayName: Jason McKenna


问:
My boss wants a narrated line-by-line English explanation of our code
I have been specifically asked to give line by line (or as appropriate - for example, image by image, etc.) explanation or commentary which my boss wants to be able to read and follow.

Since he is not a programmer, he can not follow the code so wants it all translated into English.

Has anyone been asked to do this before?

I have commented on all of the source code and used JSDoc to generate full documentation of all functions, variables, etc... and included an implementation example, and full working demos with comments throughout.

Is there anything else I can do to comment the code for non-programmers?

This isn't a reasonable request, is it?

UPDATE

In the end, I managed to explain why it was not a good use of time to do what he was asking. He is a reasonable guy, and just did not have an understanding of what my job involves. Once he saw this post, I think he quickly understood that it was not a normal request.

I did provide documentation that is suitable for another programmer to follow (JSDoc and inline comments - as well as some extra notes on technical issues), and a very broad flow chart diagram of the main logic of the program for my boss to follow.

In the end, all parties were satisfied and we have moved on.

答:
I would just say you are more than will to do it but it will take you x weeks to complete and is he sure he wants / needs you to do it?

Surely he will realise you time would be better spent elsewhere?

OwnerDisplayName: BIlly Moon

ContentLicense: CC BY-SA 3.0


问:
When conducting a code review, should the focus be on the completeness of the requirement?
Given that the reviewer is not part of the project, but was assigned to review because he has done some coding for the application being updated/enhanced.

Is it the reviewer's job to ensure that the requirement is complete and correct? Or is this the QA and business tester's responsibility?

If the developer and the reviewer misses a requirement which is discovered in UAT, is the reviewer also at fault (probably to a lesser degree)?

答:
I'll agree with Jon Hopkins answer that a code review should be mostly about the code, not the requirements.

However, if somehow the basic architecture, design or algorithms of the code under review simply cannot meet the core requirements or the spec, or are highly non-optimal for such, one might need to point this out at the beginning of the review so that much time isn't wasted going down a dead-end path.


问:
What standards does your team use for your specification documents headers and footers?

TL;DR:

What header/footer do you put on your Functional&Technical specifications to avoid people having different versions at meetings?

Story:

We're have a lot of documents, being changed by everyone. Functional specifications, technical specifications, addendums, etcetera.

Problem is offcourse that during a meeting, after an hour someone notices their printed version differs from someone else's.

I thought this could be solved by forcing everyone to use the same header/footer on each document:

Header

Project concerned

Document title (center aligned)

Document author (right aligned)

Footer

Last modification date

Date on which document was printed

Full document path and name (which always include the version number)

Page X of Y

This way, we could all easily check the filename and last modification date before starting the meeting, and make sure everyone has the same copy and is talking about the same document.

Would this work? Am I missing something? What do you guys use for your specifications to avoid versioning problems?

答:
Don't show too much information at the top and the bottom of every page. It brings nothing but distraction.

In general, you put on every page the page number, the document title (including, optionally, the name of the project), and that's pretty all. If the document is long (read more than thirty pages), you may also include the chapter/part, but this has a problem when the document is maintained by the people without much technical background: they usually don't know how to do this properly in text editing programs they use.

Don't use version number neither. Some people have no problems with this. Others, like me, are completely unable to remember to update the version number in a header when they update the document.

What you can do to make it easier to manage different versions (and what is done by many companies from what I've seen) is to put on the first page the list of document revisions, with date, author name and a summary of changes.

There are two other things you can do, but they are less related to the document, and more to the people and the organization of the meeting:

Before the meeting, ask everyone if they have downloaded the latest version of the document. Saying "remember, the document was updated yesterday evening" may help people figuring out that they may have forgotten to check for the latest version.

Don't print documents. If inside your company, everyone or nearly everyone has a notebook, why would they have a paper version of the document? Why would they reprint it again and again at every revision? A twenty pages document with thirty revisions printed by fifteen people in the team can have a big cost, both for your company and for the environment.

If you don't have enough laptops, investing in a large screen or a projector for your meeting room can be a good alternative (even if one document per person is much more comfortable).


问:
Java Vs .NET Vs Oracle(DBMS), Which technology is for Long Term Career?
I want to know about Which language is best for long term career and How?

Which language should I choose among Java and .NET Platform or Should I choose Oracle like DBMS Language (SQL/PLSQL)? I am confused?

Detailed answer would be appreciated.

答:
If you look back 15-20 years, what were big then?  Facebook, Google, and Apple's current form in terms of iPod, iPhone and iPad were still years away. Windows 95 was the big consumer O/S, browsers wars hadn't started yet, and Y2K was still a threat.

Anyone trying to predict the next big thing that will last for 20 years should be careful to look at former top dogs.  Remember when Netscape, Yahoo! and AOL were the Internet kings with the latter buying Time Warner?  Remember when the Japanese were considered the big threat in the late '80s?

How about back when Atari, Sega and Nintendo were the game makers? There are probably tons of these stories, but my point is that if you are going to try to build your career on one technology, be aware that it probably won't be the same decades later.  I wonder how COBOL has changed as hardware advances happened for another idea...

ContentLicense: CC BY-SA 2.5


答:
The best way to manage document control is to have a clear and well documented configuration management policy. This policy should address versioning of everything related to the project, from external libraries to code to documentation. In the same location, you can also address change management - how you deal with changes to any aspect of the project, from requirements through your code.

The key is to have some kind of system to track changes and revisions. At work, we use SharePoint. You could probably get away with using any version control system, but you are

You probably keep code in a version control system. The idea is that you do the same with documents, although you probably want to enable locking for documents since merging binary files (Word Documents and so on) might not be possible.

The official versioned document should be kept on the corporate intranet or someplace with appropriate security and access control. At work, we use SharePoint, which handles versioning as well. If you use some other technology or tools, you might be able to leverage that (perhaps with plugins or extensions). Just make sure everyone knows where to go to find the latest and greatest official documentation.

It's also necessary to keep track of not only the current version identifier, but also a revision history, inside the document. This way, when you print the document, it becomes easy to "diff" them and figure out what sections have been modified between any two physical copies.

Just to describe what, specifically, our documents look like:

The first page is a cover page. The corporate or project logo is in the top left corner. The document ID, late modified date, and revision ID are in the top left corner. Classification markings are centered in the header and footer. The document title is roughly centered on the page. Below the title comes all applicable copyright and distribution notices.

On all other pages, the header contains classification markings in the center and the document name in the right corner. The footer contains the document ID and revision ID in the left corner, the classification markings in the center, and the page number in the right.

The next page is the approval sign off page. It contains the document title and ID number, along with the signatures and dates of the preparer and approvers. On official versioned copies, the document actually has an image with the signatures in it.

The third page is the revision record, which again as the document title and ID, followed by a table that provides a revision ID (usually a letter), any change requests associated with the revision for tracking back to defect reports (yes - we file defects against documents), the date of the revisions, and the pages/sections modified.

Title: What standards does your team use for your specification documents headers and footers?

Body:
TL;DR:

What header/footer do you put on your Functional&Technical specifications to avoid people having different versions at meetings?

Story:

We're have a lot of documents, being changed by everyone. Functional specifications, technical specifications, addendums, etcetera.

Problem is offcourse that during a meeting, after an hour someone notices their printed version differs from someone else's.

I thought this could be solved by forcing everyone to use the same header/footer on each document:

Header

Project concerned

Document title (center aligned)

Document author (right aligned)

Footer

Last modification date

Date on which document was printed

Full document path and name (which always include the version number)

Page X of Y

This way, we could all easily check the filename and last modification date before starting the meeting, and make sure everyone has the same copy and is talking about the same document.

Would this work? Am I missing something? What do you guys use for your specifications to avoid versioning problems?


问:
I am learning Java and thinking about how and when to learn Android?
I am learning Java and I was wondering about when it would be best for me to try to develop something for Android? I have two specific concerns.

1.How is the Android API different from the main Java API? Are they similar or radically different?

2.I have heard that you need to make multiple versions of a given application for different devices. Is this correct?

I have no idea where to start when answering these questions.

答:
The android api is slightly different from regular java. For example, most likely, your used to creating Swing (or even awt) applications, in which you create the GUI in the java code. In android programming, you create your UI in XML and give each element an ID that you call in your code. this makes everything more dynamic. In addition, Android programming is probubly closer to applet programming than regular Swing programming, in that instead of one main method, there are several different methods. one for creating, one for starting, one for stopping, and one for destroying the application.

for Creating, it is:

```<code>    @Override
       onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
       }
</code>```

then for starting, there is a:

```<code>    @Override
       onStart() {
         super.onStart();
       }
</code>```

then for stoping, there is a:

```<code>    @Override
       onStop() {
         super.onStop();
       }
</code>```

then for Destroying the application there is:

```<code>    @Override
       onDestroy() {
         super.onDestroy();
       }
</code>```

while all of this may seem different, it is relatively easy once you get the hang of it. I learned simply by reading Android Application Development For Dummies, that's what I would recommend. it's not all that different from regular java once you get passed the layout and life cycle.

Body:
The android api is slightly different from regular java. For example, most likely, your used to creating Swing (or even awt) applications, in which you create the GUI in the java code. In android programming, you create your UI in XML and give each element an ID that you call in your code. this makes everything more dynamic. In addition, Android programming is probubly closer to applet programming than regular Swing programming, in that instead of one main method, there are several different methods. one for creating, one for starting, one for stopping, and one for destroying the application.

for Creating, it is:

    @Override
       onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
       }

then for starting, there is a:

    @Override
       onStart() {
         super.onStart();
       }

then for stoping, there is a:

    @Override
       onStop() {
         super.onStop();
       }

then for Destroying the application there is:

    @Override
       onDestroy() {
         super.onDestroy();
       }

while all of this may seem different, it is relatively easy once you get the hang of it. I learned simply by reading Android Application Development For Dummies, that's what I would recommend. it's not all that different from regular java once you get passed the layout and life cycle.


问:
What are the advantages of showing line numbers in a text editor?
I feel weird when I'm editing code in an IDE that does not have line numbers in the text editor.

The questions I have are:

Are line numbers visually excessive, particularly when a find by line function exists in your IDE of choice?

What are the uses of showing line numbers?

答:
I've come from a history of using editors with line numbers embedded in them. My thoughts on the matter? They're absolutely unneeded (I now use Vim with line numbers disabled). Think about this: Even when you do get stack traces and such, how many times do you manually look for the line using line numbers as opposed to ctrl+g (in most Windows editors) or :line-num in Vim?

Edit: Of course, this may be different for others, but 99% of the time, I use the latter.


答:
Displayed line numbers are essential for paired-programming. There is no faster way to direct your pair's eyes to the code you are thinking about.

By extension, line-numbers are also extremely useful for code-reviews, both formal and informal.

Title: What are the advantages of showing line numbers in a text editor?

Body:
I feel weird when I'm editing code in an IDE that does not have line numbers in the text editor.

The questions I have are:

Are line numbers visually excessive, particularly when a find by line function exists in your IDE of choice?

What are the uses of showing line numbers?


答:
No, I like having the data to give me an idea of where is something in a file, especially if I'm looking at a big configuration file where it may not be easy to find that spot again.

I may glance at the line number as a way for me to see how big is a file.  If there are a few thousand lines of code in a file then it may be time to consider if that file should be broken up or something.  I can also use it to judge how deep am I in a file if I have a ballpark of the file size and which numbers are on my screen.  I like the idea of quantifying my location within the scroll bar, e.g. I'm in the top quarter of the file or 3rd quintile.


答: Nobody mentioned being able to quickly look at an exception stack trace to find out where an exception occurred.</p>


答:
The only time I've used line numbers is when a bug pops up and the stack trace tells me that it has happened at line x.

I've seen many professional developers working without line-numbers. So, I see no usage other than late referencing.


答: Ask them Why or what their motivation for the request is, then honestly determine the costs involved and share them with the requester. If this is an unreasonable and possibly malicious request, then find another job.</p>

Title: My boss wants a narrated line-by-line English explanation of our code

Body:
I have been specifically asked to give line by line (or as appropriate - for example, image by image, etc.) explanation or commentary which my boss wants to be able to read and follow.

Since he is not a programmer, he can not follow the code so wants it all translated into English.

Has anyone been asked to do this before?

I have commented on all of the source code and used JSDoc to generate full documentation of all functions, variables, etc... and included an implementation example, and full working demos with comments throughout.

Is there anything else I can do to comment the code for non-programmers?

This isn't a reasonable request, is it?

UPDATE

In the end, I managed to explain why it was not a good use of time to do what he was asking. He is a reasonable guy, and just did not have an understanding of what my job involves. Once he saw this post, I think he quickly understood that it was not a normal request.

I did provide documentation that is suitable for another programmer to follow (JSDoc and inline comments - as well as some extra notes on technical issues), and a very broad flow chart diagram of the main logic of the program for my boss to follow.

In the end, all parties were satisfied and we have moved on.


答: I create "in English" explanations for almost every other line of my code - in the code comments. I don't see this as an unreasonable burden. Certainly the way you describe it, it seems a bit fishy. Anything more than that is a red flag that you might have an unreasonable boss or there is a problem with your working relationship.</p>


问:
Should the build drive your tags or should the tags drive the build?
Our current method of creating a product release is to tag all of our component repositories with the next appropriate version and then modify a master build script with these new version numbers for each component.  The master build script will then be run and it will perform a SCM checkout of each component, then modify the AssemblyInfo.cs file so that the compiled .exe (or .dll) has the correct version number, and then compile the component.  All of these components are then coalesced into a product release which is "versioned" with a pure marketing decided number.

So our process falls under the "tags drive the build" description, but I am not certain that is the best method.  Specifically, where I see this failing us is if we were to integrate our release build into the CI process, it seems like it would be backwards.

Not just that, but where in a typical release-management process does the decision for the new component version numbers come in? Someone has to decide when component A goes from 2.1.4 to 3.0.0 and if library B should change from 6.3.2 to 6.3.3 or 6.4.0.  Where are these version numbers stored and at what stage are they decided?  Currently, we make these decisions at the "last moment" and they are stored in the master build script.  The master build script itself is versioned and is tagged with the "marketing" version number.

答: The way we usually work is we branch with a meaningful name so we know what it is, and tag with an incremental version number as the final release. A smaller increment for a small change (1.2 -> 1.3) and a larger increment (1.0 -> 2.0) for larger features.</p>


问:
Is there a such thing as a Program Manager for Outsourcing Companies?
Accordingly to the first paragraph of Joel's post, a Program Manager is a very good thing to have in products. But what about having a Program Manager for a company that doesn't have a product, but have projects?

The only coincidence that I'd see if you ask me and ask me to answer right away is that a Program Manager for an outsourcing company would be someone that oversees all the projects that the company have, ensuring that the things are being done aligned to the company strategy, from a technical point of view.

答:
It depends on the project.

If you're working on a large project that may have several sub-projects, each of the sub-projects will need a manager, and the overall project will also need a manager. If the project is large enough or the account important enough, that person could have a title of "Program Manager".

OwnerDisplayName: Sebastian


答:
Yes, as @maple_host says, it's really convenient to do a "vi file.py +142" when I see an exception originating from code at that line number. Plus the other mentioned advantages with paired programming etc... It is always beneficial to have the line numbers on, on any editor. (I remember the vague compile error reported by MS VC++ 6 in one of the standard header files, line #blah!!.. It was actually a macro redefinition done by myself!!). Find and kill.

regards,
Yati Sagade


答: I like to have it when I use split screen in jEdit.</p>


答:
Anything that aids communication is a plus.

It doesn't take up much space so no, it's not excessive if you or any of your colleagues find it useful to discuss the code.

Even if you don't do pair programming, it is useful for "over the shoulder" code reviews if you don't use tools like Code Collaborator (we don't right now).

Also if you have team members in other sites (we do), it's useful for discussing code via IM or on the phone.

How can you tell them tell them to go to line 1842 if you can't see the line?

For me it's an invaluable simple little tool. Even some of our pdf specs have numbered lines, and it's amazing how much easier it is to refer to and discuss compared to the unnumbered ones.


问:
What does artifact mean?
The dictionary defines artifact as:

artefact, artifact [ˈɑːtɪˌfækt]
  n

something made or given shape by man, such as a tool or a work of art, esp an object of archaeological interest

anything man-made, such as a spurious experimental result

(Life Sciences & Allied Applications / Biology) Cytology a structure seen in tissue after death, fixation, staining, etc., that is not normally present in the living tissue

The word artifact often appears in software development, software development cycles, effort estimation, etc. But the above definition doesn't make sense to me in that context.

Could someone please explain this word by giving some specific examples from software industry?

答: In graphics programming, its often used to reference part of an image that did not render correctly.  For example, if a small piece of a previous frame or view is still left on screen after drawing is done, that'd be referred to as an artifact.</p>

Title: What does artifact mean?


问:
Namespace and class name guidelines
I'm having problems naming my classes and services correctly when utils and other help classes are involved.

How would you structure the following:

```<code>EventService.cs
EventServiceUtils.cs
EventServiceValidators.cs
EventServiceCoordinator.cs
</code>```

etc...

I have multiple services with the same needs as the above service. One thought is to separate all of this into a suitable namespace, making it look something like this:

```<code>Services.EventService.EventService.cs //(the actual service)
Services.EventService.Validators.DateValidator.cs
Services.EventService.Validators.ParticipantValidator.cs
Services.EventService.Coordinators.ParticipantCoordinator.cs
Services.EventService.ExtensionMethods.Extensions.cs
</code>```

and so on. Every namespace is of course a separate folder. But this doesn't feel 100%, since there are probably more DateValidators in the other services, which can easily lead to an unwanted reference.

And also the Services.EventService.EventService.cs includes the class name in the namespace, which is no good either. You could use Services.Event.EventService.cs, but there is of course already an entity with that name.

This is the domain model.

答:
I think the single biggest thing you could do to improve your namespacing here is to remove Service from your EventService namespace. I'd also adjust the namespaces to be more like this:

```<code>Services.Events.EventService.cs //(the actual service)
Services.Events.EventExtensions.cs
Services.Events.ParticipantCoordinator.cs
Services.Validators.DateValidator.cs
Services.Validators.ParticipantValidator.cs
</code>```

I still think that could use some improvement though.

I used to like namespaces, but nowadays I think less is more. Deeply nesting your namespaces can make your code too verbose, and breaking things down to far reduces your ability for inheritance. In your code for example, a DateValidator class could easily be used elsewhere, so it shouldn't have many namespaces above it, since services other than the EventService can now take advantage of a DateValidator class. The same applies to the extension methods. There's no time (that I can see) where you'd need to see all your extension methods at the same time, therefore it makes more sense to group it with the thing that it relates to. In this case, EventExtensions probably links to your EventService, so logically they should sit together in my opinion.

OwnerDisplayName: Mattias

Title: Namespace and class name guidelines

Body:
I think the single biggest thing you could do to improve your namespacing here is to remove Service from your EventService namespace. I'd also adjust the namespaces to be more like this:

Services.Events.EventService.cs //(the actual service)
Services.Events.EventExtensions.cs
Services.Events.ParticipantCoordinator.cs
Services.Validators.DateValidator.cs
Services.Validators.ParticipantValidator.cs

I still think that could use some improvement though.

I used to like namespaces, but nowadays I think less is more. Deeply nesting your namespaces can make your code too verbose, and breaking things down to far reduces your ability for inheritance. In your code for example, a DateValidator class could easily be used elsewhere, so it shouldn't have many namespaces above it, since services other than the EventService can now take advantage of a DateValidator class. The same applies to the extension methods. There's no time (that I can see) where you'd need to see all your extension methods at the same time, therefore it makes more sense to group it with the thing that it relates to. In this case, EventExtensions probably links to your EventService, so logically they should sit together in my opinion.


问:
What should you leave behind for your successors?
Assume that you're a sole developer leaving a job. What kind of information/material, outside of the code itself, should you create and leave behind for your replacement?

An obvious answer is "whatever you would want at a new job" for sure, but it's been a while since I started a new job, and I forget what the most important things that I needed were back then.

I'm thinking:

accounts/passwords

location of equipment, backups, software CDs

What else?

答:
I just recently left a job in similar circumstances to you (I wasn't the only developer, but there was really only two of us, so I had quite a lot of knowledge that the other guy didn't have (and vice versa, of course)).

In terms of the normal documentation stuff, it's important to document an overview of the whole system. Individual components are already documented in the code, but the interaction between components and why this does that or why this needs to talk to that component are important and not always easy to figure out just by debugging/looking at the code.

Then, for about a month before I left, every time I did something that only I could do, I wrote down exactly what happened, what I had to do, and why. This was usually a case of "there was a bug in xyz component, to fix it I knew to look in file abc because of X, then I had to do this, this and this".

Of course, I left my email address and phone number in case anything came up that they couldn't figure out on their own. I got a few calls in the first few weeks, but they slowly dropped off.


问:
Is performing a Waterfall every 2 weeks considered agile development?
I've been wondering if one can still classify a Waterfall type development approach, where the length of the waterfall cycle is 1-2 weeks, as Agile.</p>

答: Short answer is, no.  Agile implies iterative, adaptive development where as Waterfall implies  design upfront.  So, either you're not doing agile or you're not doing waterfall, or (most likely) you're not doing either.</p>


答:
Agile development allows you to:

Deliver working functionality rapidly

Respond to changing requirements

One of the points is to avoid the whole Big Design Up Front problem that traditional Waterfall developments which lasted for years before anything was delivered led to.

So if you are delivering something every two weeks then you are effectively doing agile (notice the lower case "a"), but not Agile (with the upper case "A"). You should be able to respond to changes as long as you are only doing the design for the current iteration and don't have some "Big Design" you're not deviating from.

Title: Is performing a Waterfall every 2 weeks considered agile development?

Body: I've been wondering if one can still classify a Waterfall type development approach, where the length of the waterfall cycle is 1-2 weeks, as Agile.</p>


答:
I use this convention:

Documents are always checked into a subversion repository. They don't have the version in their name, so that there is a clear revision history in subversion, and so that they have a permanent https://subversionserver/path-to-document URL that can be shared with people.

The first page of the document contains a table describing each version with version number, author, summary of change, and date of change. Whenever someone modifies the document they add a line on the cover page and commit the file.

Subversion locking is used to prevent concurrent edits.

Documents tend to outlive the document storage systems they are kept in, so the document must contain its own complete history.


问:
C++ to friend or not to friend
I have an object oriented programming with c++ course this semester at college and we were learning about friend functions.

I instinctively dislike them for their ability to bypass the security that Encapsulation and Data hiding provide, I read a few articles on the internet and some people thought that it was a good idea with some legitimate uses.

What would an OOPs expert say about friend fucntions in C++? Should I just skim over it or should I learn more about it?

答:
The C++ FAQ is succinct:

Use a member when you can, and a friend when you have to.

The FAQ presents one of the more useful ways of thinking about friendship:

Many people think of a friend function as something outside the class.
  Instead, try thinking of a friend function as part of the class's
  public interface. A friend function in the class declaration doesn't
  violate encapsulation any more than a public member function violates
  encapsulation: both have exactly the same authority with respect to
  accessing the class's non-public parts.

Perhaps the most common use of friend functions is overloading << for I/O.

Title: C++ to friend or not to friend


问:
Writing documentation for well understood methods like equals in Java
Is it a good practice to write comments for widely known methods like equals, compareTo etc?

Consider the below code.

```<code> /**
 * This method compares the equality of the current object
  with the object of same type
 */
@Override
public boolean equals(Object obj) {

               //code for equals

     }
</code>```

My company madates to enter comments like the above.Is the above Javadoc comment required?
Is it not obvious and well understood what the equals method and the likes (compare,compareTo) etc does?

What are your suggestions?

答:
It is extremely poor practice to litter code with vacuous comments like:

```<code>/**
 * This method compares the equality of the current object with the object of same type...
 */
</code>```

This says nothing useful.  Worse, it is poor in both style and grammar:

Comments should never start with "This method" or "This class" or "This" anything.  The comment is associated with a method or class by its location in the source file.

"the object" should read "an object"

"Compares the equality" makes sense only if the one object can have more "equality" than another.  This function does not compare "equality"; it compares objects to determine their equality with each other.

Instead, the comment should indicate when the two objects are considered equal.  Here, I would omit the method description entirely, and only document the return value, for example:

```<code>public class Fraction {
  private int numerator, denominator;
  /**
   * @return true if <i>this</i> is numerically equal to <i>other</i>
   */
  public boolean equals(Fraction other) {
    return numerator * other.denominator == other.numerator * denominator;
  }
...
}
</code>```

Generated comments for trivial get/set methods are the worst of all.

Body:
It is extremely poor practice to litter code with vacuous comments like:

/**
 * This method compares the equality of the current object with the object of same type...
 */

This says nothing useful.  Worse, it is poor in both style and grammar:

Comments should never start with "This method" or "This class" or "This" anything.  The comment is associated with a method or class by its location in the source file.

"the object" should read "an object"

"Compares the equality" makes sense only if the one object can have more "equality" than another.  This function does not compare "equality"; it compares objects to determine their equality with each other.

Instead, the comment should indicate when the two objects are considered equal.  Here, I would omit the method description entirely, and only document the return value, for example:

public class Fraction {
  private int numerator, denominator;
  /**
   * @return true if <i>this</i> is numerically equal to <i>other</i>
   */
  public boolean equals(Fraction other) {
    return numerator * other.denominator == other.numerator * denominator;
  }
...
}

Generated comments for trivial get/set methods are the worst of all.


答:
Traditional (and incorrect) waterfall is a single iteration through the phases of the lifecycle. First, you perform requirements engineering. Using those requirements, you architect and design the system and verify/validate those designs. Then, you implement the system. Once the system is implemented, you test it to ensure it works as intended. Finally, you ship it off to the customer for deployment and use. The project enters a maintenance cycle where you fix bugs and release updates, until the project is end-of-lifed. The process looks something like this:

In reality, this is a bad model for developing software. The paper where a lot of people learned about waterfall actually proposed something very different. It involves a high level of customer involvement at each phase and transitioning back to previous phases to correct and revise artifacts. You can read more about it in Royce's paper, Managing the Development of Large Software Systems. It looks something more like:

Finally, we have the agile approaches, which are iterative and incremental development models. There are many variants on iterative and incremental models. The idea in all of them is that you perform all of the lifecycle phases - requirements, architecture, design, implementation, testing, release - many times in the life of the product, until customer wants to end the product. There's no real detailed diagram of what iterative and incremental development looks like, as there are many variations, but the result is typically a feedback loop.


问:
How do I get into R&D?
I'm beginning to think that I might be best suited for a job in R&D.  The reason being that I like jobs that allow me to be creative and I generally am more interested in solving puzzles than building things.  I really dislike jobs that just boil down to translating requirements into code.

Here's the kicker though:  I don't have a bachelor's much less a masters or phd.  Is it possible for me to land a job like this?

答: Start your own research foundation and beg for grants.</p>

Title: How do I get into R&D?


问:
Emacs-as-OS: obsolete?
In an attempt to reach at least beginner status with such a legendary editor, I have been coding in Emacs for the last two months.  I try to keep an open heart, but I find myself continally disagreeing with one core design choice: that Emacs allow its users to never have to leave.  In a 2010 world, I just think that every side feature of Emacs is hopelessly behind dedicated software:

I would never use its built-in browser; Chrome is years ahead.

I would never use its dired feature; Path Finder (Mac OS X) suits my needs.

I would never use its built-in email; the Gmail web interface has more relevant features like Priority Inbox.

Etc.

Sure, I might occasionally dip into Emacs to use regexps, etc. for one of the above tasks, but other than regexps, I really see no reason to ever touch those side features.  I'm a completely newbie, yet I have a strong gut feeling that Emacs-as-an-OS is obsolete.

Emacs experts, do you think that Emacs' choice to be a comprehensive environment is the right choice for 2010 and the future?  Are there particular peripheral features that are still at or ahead of their time compared to alternatives?

答:
I don't wish to start a holy war, actually, there was a time when I've used emacs each second day (one day vim, one day emacs). There's nothing wrong with emacs, it is indeed great tool. Great, great tool.

But as a true vim'er, I was always a bit frustrated with the fact that many emacsers are trying to use emacs literally everywhere, for literally all tasks.

Reading mail, querying database, reading pdf's - those are the most innocent of tasks I've seen to be "emacsificated".

So, as for me, there are tree main areas of using emacs:

Text-editing. And it's mind-blowing, super tool. Believe me, after using vim or emacs for long time, you will totally miss its features in most advanced of IDEs.

IDE. Well, it could be done. Moreover, it could somehow compete with modes IDE's. But the fact is that to make it really competitive, you should invest hard.
You should try to assemble many different scripts. You should even write your own snippets of code. I wouldn't, to be honest.

Other tasks, most of them exotic or even esoteric. Playing tetris and so on. Better not.

Title: Emacs-as-OS: obsolete?


问:
Developing a simple web-application?
I decided to do a mini-project by myself to help me understand a bit more about developing web applications before starting the new university semester. Using the Java SE and JEE/J2EE platforms. I will be creating a simple web application that will retrieve data from a database and display the data.

I decided to use a Model-View-Controller type pattern and so far decided that the:

Models: Will be Java objects which are persisted in the database using a framework.
View: will only be the front end, probably written in HTML with some CSS.

I have not (at a high level) decided how the controller should be implemented, I initially went along with the idea that I will use JDBC to query results from the database and display it to the front end but the use of frameworks should ease the process.

I was told that there are some open source frame-works that help in making web application and a few I looked up were Spring and Hibernate.

My question then is there a way of incorporating these frameworks to what I proposed and if so how can I learn about these frameworks in order to create a web application?

Would appreciate advice and experiences about developing web-applications.
This is something I have not done before so it’s all a new and a learning process for me.

In essence I want to create is a web-application using Java as the primary programming language in which database querying functionalities help in displaying outputs to the front end.

Edit: Edited question to make it clearer for those who want to start similar type projects.

答:
I would say make a plain html website (a few pages, etc) with html5 and css. Make it pass html and css compliance.

Add some javascript to change some text to bold on the page.

Then add something simple like a page counter on a page.

Then add the page counter at the bottom of each page.

Add a form, with form values emailed to you.

Add a form with values entered displayed on screen (try to break it too by insertign html in the input values).

Scrap all that, then build a simple site in php.

Put a file uploader. Make the file save somewhere.

Put in a flash component (a video player is fun)

Put in a common header and footer in all pages.

scrap all that before you get carried away.

Go back to html5 and write an app with HTML5+css+javascript that consumes JSON that comes from a web service on your server.(see python nudge)

Scrap all that.

Write HTML5+css+javascript apps for iPhone, iPad, Android, with webservice interface.

Note that you can just bypass java and all the MVC stuff.

Title: Developing a simple web-application?


答:
The point of using a framework is that the framework developers have already implemented the functionality you're describing. Spring is probably the best-known Java Web Framework, so there's plenty of documentation and resources available to help you along.

The point of the Model part of MVC is that you don't have to write SQL by hand in most cases; you interact with model objects instead of querying directly.

You can get a brief overview and tutorial here: http://maestric.com/doc/java/spring/mvc

Title: Developing a simple web-application?

Body:
I decided to do a mini-project by myself to help me understand a bit more about developing web applications before starting the new university semester. Using the Java SE and JEE/J2EE platforms. I will be creating a simple web application that will retrieve data from a database and display the data.

I decided to use a Model-View-Controller type pattern and so far decided that the:

Models: Will be Java objects which are persisted in the database using a framework.
View: will only be the front end, probably written in HTML with some CSS.

I have not (at a high level) decided how the controller should be implemented, I initially went along with the idea that I will use JDBC to query results from the database and display it to the front end but the use of frameworks should ease the process.

I was told that there are some open source frame-works that help in making web application and a few I looked up were Spring and Hibernate.

My question then is there a way of incorporating these frameworks to what I proposed and if so how can I learn about these frameworks in order to create a web application?

Would appreciate advice and experiences about developing web-applications.
This is something I have not done before so it’s all a new and a learning process for me.

In essence I want to create is a web-application using Java as the primary programming language in which database querying functionalities help in displaying outputs to the front end.

Edit: Edited question to make it clearer for those who want to start similar type projects.


答:
I highly recommend picking up a copy of the JEE on Glassfish book and working through that. J2EE is the older Java Enterprise technology and should be avoided.  Spring and Hibernate are wrappers around various JEE APIs and I'd recommend moving onto those technologies a little later once you've gone through the basics.

You can use JDBC to talk to the database, but the preferred JEE way (for simple CRUD applications) is to use JPA (which Hibernate is an implementation of).

Title: Developing a simple web-application?


答:
tough call.

In case like you describe I'd probably use cost of design errors as determining factor.

Say, if it takes a month or two to recover from design error discovered at testing stage and if that happens frequently enough to cause pain then that certainly smells like a typical Waterfall issue to me. Otherwise, it seems to be just good enough to stop worrying about terminology.


答: I've only heard artifact used on one project I've been on: We used it to refer to the files our build put out. However, by reading the other answers, it seems that 'Artifact' is a variable term, used whenever somebody needs a term for some project-specific object type.</p>

Title: What does artifact mean?

Body:
The dictionary defines artifact as:

artefact, artifact [ˈɑːtɪˌfækt]
  n

something made or given shape by man, such as a tool or a work of art, esp an object of archaeological interest

anything man-made, such as a spurious experimental result

(Life Sciences & Allied Applications / Biology) Cytology a structure seen in tissue after death, fixation, staining, etc., that is not normally present in the living tissue

The word artifact often appears in software development, software development cycles, effort estimation, etc. But the above definition doesn't make sense to me in that context.

Could someone please explain this word by giving some specific examples from software industry?


答:
If you are shipping a version every 2 weeks, then you must have something a bit unusual.

Either your business is constantly changing, the size of implementation you are undertaking in each cycle is so small, or your user is not providing the full picture of requirements.

All of the above is very risky and can be fixed by proper up-front analysis and design.

If you release your software every 2 weeks, you will possibly need to spend considerable time in regression testing, documentation, production support education, user training, etc. Also, the water fall style is not based on iterative cycles and has no accommodation for regression testing.

I am also concerned about the end-user feel for a change in the software every 2 weeks. Personally, I don't want to see a new menu item on the application every so often that does something new...

If I were you, I would study the true value of having a 2-week cycle.


问:
Being stupid to get better productivity?
I've spent a lot of time reading different books about "good design", "design patterns", etc. I'm a big fan of the SOLID approach and every time I need to write a simple piece of code, I think about the future. So, if implementing a new feature or a bug fix requires just adding three lines of code like this:

if(xxx) {
    doSomething();
}
```

It doesn't mean I'll do it this way. If I feel like this piece of code is likely to become larger in the nearest future, I'll think of adding abstractions, moving this functionality somewhere else and so on. The goal I'm pursuing is keeping average complexity the same as it was before my changes.

I believe, that from the code standpoint, it's quite a good idea - my code is never long enough, and it's quite easy to understand the meanings for different entities, like classes, methods, and relations between classes and objects.

The problem is, it takes too much time, and I often feel like it would be better if I just implemented that feature "as is". It's just about "three lines of code" vs. "new interface + two classes to implement that interface".

From a product standpoint (when we're talking about the result), the things I do are quite senseless. I know that if we're going to work on the next version, having good code is really great. But on the other side, the time you've spent to make your code "good" may have been spent for implementing a couple of useful features.

I often feel very unsatisfied with my results - good code that only can do A is worse than bad code that can do A, B, C, and D.

Is this approach likely to result in a positive net gain for a software project, or is it a waste of time?

答:
Ask yourself what the advantages of a good design are:

Easier to understand

Easier maintains

Portable

Stays useful for a long time

Easy to add new features

Now, ask yourself if adding all those layers of abstractions really add to any of the points mentioned above. If it does not, you are doing it WRONG.

If you are able to add a new features by adding 3 lines of code like this:

if (condition()) {
  doSomething()
}
```

Then please, please do so. This indicate your previous design was good and easy to adapt. Only once your classes start to grow beyond a certain extend, use refactoring to split functions and possibly extract new classes.

My rule of thumb is that new features should be implemented as minimalistic as possible, only when something is to big to grasp upfront (lets say, takes more then 1 day or half a day to implement) you can add a rough global design.
From there on, only add abstraction layers when the size of the code grows. You then refactor afterwards! After a while it should even come natural to you when you need to design a piece a little more, or go for the quick road.
Another indication some code can use some cleanup is when you reuse it. Each time you add a new feature, or call old code in a new place, it's a good time to look at the old code and see if you can improve it a little before you add to it again. This way, hot code will slowly become more cleanly, while the uninteresting parts slowly rot away and don't take any of your valuable time. (If you use some old code, and you fail to quickly understand it, this might be a demotivation to improve on it, but remember that is also a big warning some cleanup/redesign is appropriate).

If you work like this, you will never over-design anything. It might take some discipline to go back to old code when you want to add something new, or to leave new code slightly more ugly then you like, but you will be working towards something productive instead of over engineered.

Body:
Ask yourself what the advantages of a good design are:

Easier to understand

Easier maintains

Portable

Stays useful for a long time

Easy to add new features

Now, ask yourself if adding all those layers of abstractions really add to any of the points mentioned above. If it does not, you are doing it WRONG.

If you are able to add a new features by adding 3 lines of code like this:

if (condition()) {
  doSomething()
}

Then please, please do so. This indicate your previous design was good and easy to adapt. Only once your classes start to grow beyond a certain extend, use refactoring to split functions and possibly extract new classes.

My rule of thumb is that new features should be implemented as minimalistic as possible, only when something is to big to grasp upfront (lets say, takes more then 1 day or half a day to implement) you can add a rough global design.
From there on, only add abstraction layers when the size of the code grows. You then refactor afterwards! After a while it should even come natural to you when you need to design a piece a little more, or go for the quick road.
Another indication some code can use some cleanup is when you reuse it. Each time you add a new feature, or call old code in a new place, it's a good time to look at the old code and see if you can improve it a little before you add to it again. This way, hot code will slowly become more cleanly, while the uninteresting parts slowly rot away and don't take any of your valuable time. (If you use some old code, and you fail to quickly understand it, this might be a demotivation to improve on it, but remember that is also a big warning some cleanup/redesign is appropriate).

If you work like this, you will never over-design anything. It might take some discipline to go back to old code when you want to add something new, or to leave new code slightly more ugly then you like, but you will be working towards something productive instead of over engineered.


问:
My boss wants a narrated line-by-line English explanation of our code
I have been specifically asked to give line by line (or as appropriate - for example, image by image, etc.) explanation or commentary which my boss wants to be able to read and follow.

Since he is not a programmer, he can not follow the code so wants it all translated into English.

Has anyone been asked to do this before?

I have commented on all of the source code and used JSDoc to generate full documentation of all functions, variables, etc... and included an implementation example, and full working demos with comments throughout.

Is there anything else I can do to comment the code for non-programmers?

This isn't a reasonable request, is it?

UPDATE

In the end, I managed to explain why it was not a good use of time to do what he was asking. He is a reasonable guy, and just did not have an understanding of what my job involves. Once he saw this post, I think he quickly understood that it was not a normal request.

I did provide documentation that is suitable for another programmer to follow (JSDoc and inline comments - as well as some extra notes on technical issues), and a very broad flow chart diagram of the main logic of the program for my boss to follow.

In the end, all parties were satisfied and we have moved on.

答: We have all had managers at some point or another that want something ridiculous like this.  It's hard to not go off half cocked, but it is important that you don't- he'll just dig in.  Maybe you can make him a list of pros and cons and go through them with him.  In my opinion, the first item in the con side is good code is self documenting.  But they hardly ever fall for that.</p>


问:
Alternative for Access+SQL Server for enterprise projects
We're a small software company, developing projects for manufacturing facilities about analysis, traceability, reporting etc. We're using Access for front end, SQL Server for back end. We've quite big customers too and our company is growing. So far it is working fine but I wonder should we move to more influential technologies, such as web based solutions. What do you think about the future of Access?</p>

答:
If it is not broken don't fix it. I have used this phrase 2 times this day, and I am not sure it is professional enough but reality proves it is correct time after time...

It is good to anticipate change and be ready for it, but first, you need to clearly define your problem, for example:

Do you anticipate large volume of data?

Is there a lack of expertise in the current application?

Major changes in logic?

Do you anticipate more users?

Need for distributed processing?

Need for web access?

Need to support special devices?

Need to have more secured application?

And so on...

Without answering those questions, you will not be able to pick the right solution for the problem.

Fact: Any technology you pick today will be history in few years time. For example, WPF is now not as fancy as it was promised to be because Silverlight is the new kid in town and even that is being challenged by HTML5+JavaScript and the story goes on and on.

Make sure you add to the above list, the time you anticipate the change is need for and the ability of your staff or your organization to invest in human intellect needed for the migration.


答:
I think that over-engineering often seems from insecurity about writing code.
All abstract principles and patterns should be treated as tools to help you.
What often happens is that they are treated as standards, one must conform to.

I believe that a programmer is always in a better position to decide how to abstract than an axiom.

The rest has already been said by KeithS

Title: Being stupid to get better productivity?

Body:
I've spent a lot of time reading different books about "good design", "design patterns", etc. I'm a big fan of the SOLID approach and every time I need to write a simple piece of code, I think about the future. So, if implementing a new feature or a bug fix requires just adding three lines of code like this:

if(xxx) {
    doSomething();
}
```

It doesn't mean I'll do it this way. If I feel like this piece of code is likely to become larger in the nearest future, I'll think of adding abstractions, moving this functionality somewhere else and so on. The goal I'm pursuing is keeping average complexity the same as it was before my changes.

I believe, that from the code standpoint, it's quite a good idea - my code is never long enough, and it's quite easy to understand the meanings for different entities, like classes, methods, and relations between classes and objects.

The problem is, it takes too much time, and I often feel like it would be better if I just implemented that feature "as is". It's just about "three lines of code" vs. "new interface + two classes to implement that interface".

From a product standpoint (when we're talking about the result), the things I do are quite senseless. I know that if we're going to work on the next version, having good code is really great. But on the other side, the time you've spent to make your code "good" may have been spent for implementing a couple of useful features.

I often feel very unsatisfied with my results - good code that only can do A is worse than bad code that can do A, B, C, and D.

Is this approach likely to result in a positive net gain for a software project, or is it a waste of time?


问:
Managing references in open source .NET project?
What is the best practice for managing references in a .NET open source project? I'm writing a small library that will use Json.NET. Should I check the Json.NET DLL straight into source control?</p>

答:
Yes you should - either that or reference the original project's version control directly (ie use SVN's externals feature to grab the relevant revision from the source repo, or have a link to get the right version of the project's source).

Put the dll in a slightly separate part of your repo though - do not bundle it in your /bin/release directory, you'll find it much easier to work with 3rd party dlls if there is a clear distinction between what is your code and what is theirs - especially when you come to replace or modify it.


答:
If the licensing allows for including the binaries in your source control and distributing them, it makes alot of sense to include them for a few reasons. First and foremost is ease of development on you -- you don't need to go track down a dependency every time you want to hack on a different machine. Second is ease of development on folks also hacking on your library -- they won't have to go through the same gymnastics. Finally and perhaps more important, it makes sure you've got the correct version of the library traveling with your code.

In the case of JSON.NET, I believe it is MIT licensed which means you can definitely do it from a legal perspective. Add away. Preferably via nuget so I don't have to download it twice if I don't need it.

Title: Managing references in open source .NET project?

Body: What is the best practice for managing references in a .NET open source project? I'm writing a small library that will use Json.NET. Should I check the Json.NET DLL straight into source control?</p>


答:
heres what I do:  I create a solution folder for my 3rd party assemblies, I then add them to the source control and check them in. this way, they are distributed with my project.  Of course, this is all subject to the distribution licenses of the various 3rd party assemblies.

I hate it when I dl an Open Source project and then I have to go and hunt down assemblies--especially when those assemblies may no longer be available.


答:
One big thing: If you're using Visual studio or any ide with collapsible regions, line numbers give you an instant feel for how big an area is without expanding it.
In addition, if you have some sort of logging directing you to a problem line, it's nice to not need to use a command when it's the line is right in front of you.</p>


问:
How to Quantify the Value of Unit Testing
Our organization is considering integrating unit testing into our software development workflow. I've heard lots of anecdotal stories about how it encourages better, easy to maintain, and well-planned code. As a programmer, I understand the benefits.

However, in order to build consensus around using unit testing in projects that might affect customers, I would like to demonstrate its value quantitatively, in terms of saving hours of developer time.

Does anyone in the community have any historical data or experience they would be willing to share as quantitative evidence in my case for unit testing?

答:
Unit testing is cheap.

Each time you run a unit test, you didn't have to pay a tester to perform that test manually, or perform the test yourself, by hand.  A computer can perform the same tests over and over tirelessy, with perfect fidelity (executing the test in exactly the same way every time).

Each time an automated test catches a bug you missed during refactoring, you save money by preventing QA people from having to report it, and untold money and reputation capital by preventing that bug from going out the door to a customer.

Automated testing, especially unit testing, saves money because it catches bugs early.  The later a bug is found, the more expensive it is (by orders of magnitude):


答:
I would say that your best bet, without getting a higher education, is likely to find out everything you possibly can about the field you intend to do research. Then independently produce some high quality papers and proofs of concept for that area. Get the papers published in reputable journals and get the proofs in the hands of other researchers in the field.

From there, you can look at companies that are doing research in the same areas and consider applying.

Title: How do I get into R&D?

Body:
I'm beginning to think that I might be best suited for a job in R&D.  The reason being that I like jobs that allow me to be creative and I generally am more interested in solving puzzles than building things.  I really dislike jobs that just boil down to translating requirements into code.

Here's the kicker though:  I don't have a bachelor's much less a masters or phd.  Is it possible for me to land a job like this?


答:
You could write some acceptance tests using a behaviour-driven-design framework such as cucumber?  That won't explain the code; it will explain what it does, and in natural-language.  It also has the benefit of being executable, so you can always be sure the documentation is up-to-date, because if it isn't, the test-runner will be red.

Check out the intro video.  Perhaps it's a good diversion while you find a new boss...  ;-)


问:
Pass in single settings object vs multiple setter methods?
Working with C++.  Suppose I have a class BoxFilter.  The class is used to filter boxes which have properties such as height, width, depth, weight, etc.  The filter might have something like MaxWidth so that boxes with a width greater than MaxWidth would not pass the filter.  Usage would be something like (C#-style pseudocode):

```<code>IBoxFilter filter = new BoxFilter();

foreach(Box box in boxes)
{
  if(filter.PassesFilter(box))
  {
     // do something
  }
}
</code>```

(sorry for the C# example but I think it's easier to understand)

In setting up the filter object I need to configure the settings of the filter.  The filter currently has 7 properties although it could get more over time.  I'm debating whether the filter class should have multiple setters such as SetWidthMax(), SetWidthMinimum(), SetHeightMax(), SetHeightMinimum(), etc or should I create a BoxFilterSettings object/struct and then have a single method on the box filter class called SetSettings(BoxFilterSettings settings)?

答:
Two words: Builder Pattern. And also, you're welcome.

For example:

```<code>class BoxFilter {
    friend BoxFilterBuilder;
    private int height;
    private int width;
};
class BoxFilterBuilder {
    int height_;
    int width_;
    public:
    BoxFilterBuilder& height(int x) {this.height_ = x; return *this;}
    BoxFilterBuilder& width(int x) {this.width_ = x; return *this;}
    BoxFilter build() {
        BoxFilter filter;
        filter.height = height_;
        filter.width = width_;
        return filter;
    }
};
</code>```

Usage is something like this:

```<code>BoxFilter filter = BoxFilterBuilder().height(12).width(1).build();
</code>```

As you can see the syntax is clear and remains so regardless the number of construction parameters. And the box filter is always constructed in a correct state (you can guarantee that with some validations in your build() method. Further you can force creation via the builder by making the constructor of BoxFilter private.

Body:
Two words: Builder Pattern. And also, you're welcome.

For example:

class BoxFilter {
    friend BoxFilterBuilder;
    private int height;
    private int width;
};
class BoxFilterBuilder {
    int height_;
    int width_;
    public:
    BoxFilterBuilder& height(int x) {this.height_ = x; return *this;}
    BoxFilterBuilder& width(int x) {this.width_ = x; return *this;}
    BoxFilter build() {
        BoxFilter filter;
        filter.height = height_;
        filter.width = width_;
        return filter;
    }
};

Usage is something like this:

BoxFilter filter = BoxFilterBuilder().height(12).width(1).build();

As you can see the syntax is clear and remains so regardless the number of construction parameters. And the box filter is always constructed in a correct state (you can guarantee that with some validations in your build() method. Further you can force creation via the builder by making the constructor of BoxFilter private.


答:
Here is a chart from my experiences with and without unit testing.  How many of the problems on the right-hand column apply to your project?

```<code>                  With Unit Tests               Without Unit Tests
----------------- ----------------------------- -----------------------------
Development       Code/Test/Refactor            Cut and Paste/Hack
Process           or Test/Code/Refactor         to minimize code change
                                                and avoid complete retest

Module Coupling   Limited by continuous         Tangled due to need to
                  refactoring                   add features with minimal
                                                code change

Program Design    Evolving through Refactoring  Frozen due to risk of change

Velocity          Increasing as higher-level    Decreasing as code volume and
over Time         functions are factored out    coupling increase

Bugs detected     Mostly by developer           Mostly by QA or Customer

Cost of bugs      Lower                         Higher
</code>```

You should be able to point to specific instances where the code volume was increased unnecessarily, or the module coupling was increased to minimize the need for retest.  However, if they don't believe they have a problem, and are not interested in improvement, there may be little you can do.  Even when continued maintenance becomes uneconomical, they may believe that is simply the normal end of all software projects.

I have been successful in improving testing only when management knew they should be testing, but weren't sure how to do it economically.  When an organization is uninterested in process improvement, great patience is needed to effect change.  How patient are you?

Title: How to Quantify the Value of Unit Testing

Body:
Our organization is considering integrating unit testing into our software development workflow. I've heard lots of anecdotal stories about how it encourages better, easy to maintain, and well-planned code. As a programmer, I understand the benefits.

However, in order to build consensus around using unit testing in projects that might affect customers, I would like to demonstrate its value quantitatively, in terms of saving hours of developer time.

Does anyone in the community have any historical data or experience they would be willing to share as quantitative evidence in my case for unit testing?

Body:
Here is a chart from my experiences with and without unit testing.  How many of the problems on the right-hand column apply to your project?

                  With Unit Tests               Without Unit Tests
----------------- ----------------------------- -----------------------------
Development       Code/Test/Refactor            Cut and Paste/Hack
Process           or Test/Code/Refactor         to minimize code change
                                                and avoid complete retest

Module Coupling   Limited by continuous         Tangled due to need to
                  refactoring                   add features with minimal
                                                code change

Program Design    Evolving through Refactoring  Frozen due to risk of change

Velocity          Increasing as higher-level    Decreasing as code volume and
over Time         functions are factored out    coupling increase

Bugs detected     Mostly by developer           Mostly by QA or Customer

Cost of bugs      Lower                         Higher

You should be able to point to specific instances where the code volume was increased unnecessarily, or the module coupling was increased to minimize the need for retest.  However, if they don't believe they have a problem, and are not interested in improvement, there may be little you can do.  Even when continued maintenance becomes uneconomical, they may believe that is simply the normal end of all software projects.

I have been successful in improving testing only when management knew they should be testing, but weren't sure how to do it economically.  When an organization is uninterested in process improvement, great patience is needed to effect change.  How patient are you?


答: I personally prefer APIs with both.  Sometimes I just want to set one criteria, so constructing a settings object is a pain.  Other times, I want to reuse the same settings repeatedly, so setting them individually becomes a pain and I'll make my own settings wrapper object if one isn't provided.</p>

Title: Pass in single settings object vs multiple setter methods?

Body:
Working with C++.  Suppose I have a class BoxFilter.  The class is used to filter boxes which have properties such as height, width, depth, weight, etc.  The filter might have something like MaxWidth so that boxes with a width greater than MaxWidth would not pass the filter.  Usage would be something like (C#-style pseudocode):

```<code>IBoxFilter filter = new BoxFilter();

foreach(Box box in boxes)
{
  if(filter.PassesFilter(box))
  {
     // do something
  }
}
</code>```

(sorry for the C# example but I think it's easier to understand)

In setting up the filter object I need to configure the settings of the filter.  The filter currently has 7 properties although it could get more over time.  I'm debating whether the filter class should have multiple setters such as SetWidthMax(), SetWidthMinimum(), SetHeightMax(), SetHeightMinimum(), etc or should I create a BoxFilterSettings object/struct and then have a single method on the box filter class called SetSettings(BoxFilterSettings settings)?


答:
Your manager is almost certainly distressed by the fact that he doesn't understand what the people do that he's managing, and he doesn't have the background to understand the results that they produce.

I doubt he thought this solution through very thoroughly, and it probably seemed sensible to him at first glance. But that's largely because he doesn't understand what programming code actually is.

Any programmer understands the absurdity of this request, but we do because we intuitively know that once you get past the language, all that's revealed is the algorithm, which is equally cryptic.

```<code>// Set s to the first address in the server list
server_info *s = cmd->servers;
// Loop until s is NULL
while (s) {
    // call the server's init function passing our current ID and address
    s->init(proc->id,*addr);
    // call log::info with our custom message
    log::info("Starting server %s",s->name);
    // Set s to the value returned by the server's next() function
    s=s->next();
} // end of loop
</code>```

The problem here is that while the comments explain what each line does, you still have no idea what the code really does unless you understand what all the implications are. It's obvious if you're a programmer and have seen this pattern before; but show this to someone who only understands sales, and he will be just as confused after reading the comments as he was before.

You could actually save time by teaching your boss some basic programming. If he wants to read your code, give him the tools to be able to do so. Most languages are pretty compact syntax-wise, and learning the structure only takes an hour or two. He will, almost certainly, give up after a few days, but at least he'll know what he's passing on, and more importantly why he doesn't want to read your code.

Body:
Your manager is almost certainly distressed by the fact that he doesn't understand what the people do that he's managing, and he doesn't have the background to understand the results that they produce.

I doubt he thought this solution through very thoroughly, and it probably seemed sensible to him at first glance. But that's largely because he doesn't understand what programming code actually is.

Any programmer understands the absurdity of this request, but we do because we intuitively know that once you get past the language, all that's revealed is the algorithm, which is equally cryptic.

// Set s to the first address in the server list
server_info *s = cmd->servers;
// Loop until s is NULL
while (s) {
    // call the server's init function passing our current ID and address
    s->init(proc->id,*addr);
    // call log::info with our custom message
    log::info("Starting server %s",s->name);
    // Set s to the value returned by the server's next() function
    s=s->next();
} // end of loop

The problem here is that while the comments explain what each line does, you still have no idea what the code really does unless you understand what all the implications are. It's obvious if you're a programmer and have seen this pattern before; but show this to someone who only understands sales, and he will be just as confused after reading the comments as he was before.

You could actually save time by teaching your boss some basic programming. If he wants to read your code, give him the tools to be able to do so. Most languages are pretty compact syntax-wise, and learning the structure only takes an hour or two. He will, almost certainly, give up after a few days, but at least he'll know what he's passing on, and more importantly why he doesn't want to read your code.


问:
How important is it to be syntactically correct during an interview?
When asking an interview candidate to write a program on the whiteboard, do you expect the candidate to write code that is syntactically correct?

I had two candidates, one of which wrote a syntactically correct program but the logic was not up to the mark, and the other had the logic better written but the syntax was crap.

I favor the first candidate.

答:
I would favor the person who was able to reason through the problem, come up with a good solution, and then explain their solution to me. Even if their logic wasn't 100%, if they were on the right track and were reasoning through the problem, asking the right questions, and going down the right path, that would be my winner.

When you are developing code on the job, you have many tools - IDEs, compilers, static analysis, unit tests, integration test, and acceptance test procedures - to find mistakes in syntax and logic. If you're writing on a white board, you don't have these tools and you're bound to make mistakes in syntax (forgetting a method name, a semicolon, a brace), and I can forgive that.

My only question to you: Why are you having your candidates write actual code on the whiteboard, instead of focusing on algorithms, design strategies, and logical thinking? Programming languages change, problem solving doesn't.


答: I would prefer the second candidate, on the theory that a whiteboard has more impact on syntax than on logic, and that syntax mistakes are easier to correct - either the IDE or the compiler can usually do it.</p>

Title: How important is it to be syntactically correct during an interview?

Body:
When asking an interview candidate to write a program on the whiteboard, do you expect the candidate to write code that is syntactically correct?

I had two candidates, one of which wrote a syntactically correct program but the logic was not up to the mark, and the other had the logic better written but the syntax was crap.

I favor the first candidate.


答:
If you're using C++ and you're expecting the options to be known when you create the object (i.e. you're not just defaulting them to a specific value and then modifying them based on user input), then common practice is to pass in the data via either multiple parameters or a single init object in the class constructor so that you can take advantage of the initialization list.

```<code>struct BoxParams
{
    int widthMax;
    int widthMin;
};

class BoxFilter(BoxParams* params)
: mWidthMax(params->widthMax)
, mWidthMin(params->widthMin)
{
}
</code>```

Or something along those lines..

Personally, I prefer using initialization objects as the API is almost guaranteed to not change (well, at least for the initialization stuff), so you don't have to worry about issues such as parameter order when updating your initialization struct.

Body:
If you're using C++ and you're expecting the options to be known when you create the object (i.e. you're not just defaulting them to a specific value and then modifying them based on user input), then common practice is to pass in the data via either multiple parameters or a single init object in the class constructor so that you can take advantage of the initialization list.

struct BoxParams
{
    int widthMax;
    int widthMin;
};

class BoxFilter(BoxParams* params)
: mWidthMax(params->widthMax)
, mWidthMin(params->widthMin)
{
}

Or something along those lines..

Personally, I prefer using initialization objects as the API is almost guaranteed to not change (well, at least for the initialization stuff), so you don't have to worry about issues such as parameter order when updating your initialization struct.


答:
Few thoughts about syntax errors...I was wondering if you had made it clear to both that syntax needs to be correct. Sometimes people assume that pseudo code is OK.

Also, if someone claims years of experience in a language and can't make the basic syntax correct, you should doubt the claim.

Syntax errors can vary, so if someone forgets a method name it is OK (to me) but if someone does not know how to refer to a method in a class (dot notation) or does not know a basic think like the syntax for a simple class, then chances are this person has not used the language for a long time.

For the guy who did not get the syntax correct, do you think that his mistakes could have been easily fixed with the appropriate language editor? if so, I vote for him.

I guess what I am thinking of here is that syntax errors are acceptable within limits.


答:
I'm guessing that you know that your organisation isn't particularly mature and that you want to improve things and become more professional.  So, you will want to ensure you have bug tracking, version control, release control etc.

Given what you have & what you know I'd suggest dropping Access and moving to .NET winforms using VB as the programming language because that will be close to what you have at the moment but will be a lot easier to support - I don't think Access integrates well with version control for example.  Stick with SQL Server, it's a fine product.  Consider moving to C# instead of VB because C# is a better language & Microsoft is developing C# more actively.  It will be harder to make that jump though so you may want to start with VB.

Title: Alternative for Access+SQL Server for enterprise projects

Body: We're a small software company, developing projects for manufacturing facilities about analysis, traceability, reporting etc. We're using Access for front end, SQL Server for back end. We've quite big customers too and our company is growing. So far it is working fine but I wonder should we move to more influential technologies, such as web based solutions. What do you think about the future of Access?</p>


答:
I would favour the second candidate. Logic can be hard (very hard, sometimes) to get exactly right. Syntax can be very easy to get right when the IDE and compiler and other assorted tools help out.

The first candidate may never trigger a compiler error, but if his code often fails in all sorts of weird (and less weird) boundary cases, his knowing where to put a semicolon isn't worth that much.


答:
Well some people want great Java Developers, great C# developers, great C++ developers, etc.  If that's your case then go with A and more power to you.  One concern I would have is if they cannot reason to solve the problem how can you expect them to reason and solve your business problems?

Other people just want great developers who can work in whatever language is required.  They think of/model the problem and then implement it in whatever language.  If you suddenly decide .NET sucks and switch to Java or vice versa, these are the developers who won't jump ship or refuse to learn.  Also if you get some type of automation package/calculation package which has a proprietary language and you need some tasks automated, these are the types of developers who can do it.  Real life example...I needed to figure out a custom proprietary scripting language for a mapping software package in order to extract zip codes for custom drawn regions for an old employer.  Another example....my current employer has a proprietary property management system which contains a custom language for writing reports...  In any case, if you get someone who cannot think logically but is familiar with the syntax of language X, you will be in trouble when situations like this comes up where you need someone to work in a different language.

Also on the white board there is extra pressure/nervousness so no one is at their best.  Plus I highly doubt that when coding you get it perfect every time.  I suspect you compile or just run and find some errors.  Additionally it depends on the language.  C is small enough that you can probably memorize most of the language/core libraries (though I wouldn't require it).  Java/C# have such huge libraries (with such frequent changes) that memorizing the library is out of the question.

Also knowing multiple languages can work against you.  C# and Java interfere with each other with me.  But knowing multiple languages can also broaden your perspective, especially if you know a scripting language and a functional language in addition to C#/Java.

Still if both candidates solve the problem with correct logic, the guy with correct syntax probably has an advantage.  If one solves the problem and one doesn't, then personally I would go with the guy who can solve the problem.

Still if someone claims to be an expert in Java and cannot declare an array of use an if statement or while loop, they might be lying.  But I might understand if someone is an expert in Java but has been dong a lot of C# lately and tries to do Map or something....  Also if you get into specifics of the library, or someone does myArray.length instead of myArray.Length or string.length()/string.Length/string.length instead of string.length()...  Minor stuff I would forgive.  Or if they forget the argument order of some library call.  Or a typo/semi colon here or there....


问:
What alternatives are there for cross cutting concerns other than aspect oriented programming?
Aspect oriented programming promises to deal with cross cutting concerns, but I'm not completely sold on it yet. Have there been any other attempts to deal with this problem?</p>

答:
When possible, you can encapsulate cross-cutting concerns into separate modules that are then used throughout the app via dependency injection.  This allows you to somewhat decouple the cross-cutting concern implementation from it's use throughout the code.

This doesn't always work elegantly, though.  That's the reason people are trying to address the issue with things like AOP.


问:
Debugging applications
In my current developement, I have decided to keep the command prompt open so I can see debug messages. For example, if something wasn't happening when it should, I would put a cout statement at every function to determine where the broken link is. Sometimes, I might get hundreds of the same message (like WM_MOUSEMOVE) and I need to determine whether or not the messages are still coming, so I would using a static variable, and increment it, so I might have:

```<code>...
3> WM_MOUSEMOVE processed.
4> WM_MOUSEMOVE processed.
54> WM_CLICK processed.
5> WM_MOUSEMOVE processed.
...
</code>```

in my cmd. (Don't ask me why there would be 54 WM_CLICK and 4 WM_MOUSEMOVE)

What I would like to know is your opinion. Is this a good approach to debugging? What kind of syntax would you use for consistency? Does a syntax even matter? And would you make any suggestions to how this method could be improved.

答: Sometimes cout statements are easier to do, but I think exceptions are the way to go in most cases.</p>

Title: Debugging applications


问:
Why and for what reasons developers may not like "daily scrum"?
There are advantages in holding daily scrum, like:

Team get coordinated with each other

Everyone knows what amount of task has been done

Burndown chart gets more and more complete

Task board is updated

It doesn't last that much, 15 minutes won't kill anybody

However, recently (after 6 months of implementing and using scrum), I feel like that our developers don't like scrum daily that much anymore. People just update the task board, without explaining enough and it seems that  they're bored of it. I see that when for any reason, we don't hold it, they kind'of become extra-happy.

I just don't know what could be wrong with this. Are there any reasons mentioned somewhere for disadvantages the "daily scrum" can have for a team? What could be the reasons for developers getting tired of daily scrum?

答:
I would find daily stand up boring and useless if I felt there was little to no value in it.  There are a few things that can reduce the utility of a daily standup.

The information being shared never pertains or affects me in any way.

Absence of team ownership and everyone always working on their own projects.

Absence of team communication outside the standup.

Lack of visible or communicated progress.

Absence of information to share.

These are just off the top of my head, but there are always more possible reasons.

Perhaps you should just ask the developers straight out why they don't seem to be interested?  If you want more/better communication it should start with you.


答:
I've always approached Emacs as a platform rather than an out of the box solution.  There are many packages that duplicate functionality or purpose and it's up to you to decide whether they meet your needs or not.

That's also the reason why many things are out of date.  Most people (that I've met anyway) that use Emacs don't use it to read email or browse the web.  However, I'm hard pressed to find another editor that has

as sophisticated remote editing capabilities

free form inline macro creation and editing

depth and breadth of available extensions/packages

It has been my editor of choice for over a decade for software development and word processing.

Best of all I don't have to touch my mouse when using Emacs.

Title: Emacs-as-OS: obsolete?

Body:
In an attempt to reach at least beginner status with such a legendary editor, I have been coding in Emacs for the last two months.  I try to keep an open heart, but I find myself continally disagreeing with one core design choice: that Emacs allow its users to never have to leave.  In a 2010 world, I just think that every side feature of Emacs is hopelessly behind dedicated software:

I would never use its built-in browser; Chrome is years ahead.

I would never use its dired feature; Path Finder (Mac OS X) suits my needs.

I would never use its built-in email; the Gmail web interface has more relevant features like Priority Inbox.

Etc.

Sure, I might occasionally dip into Emacs to use regexps, etc. for one of the above tasks, but other than regexps, I really see no reason to ever touch those side features.  I'm a completely newbie, yet I have a strong gut feeling that Emacs-as-an-OS is obsolete.

Emacs experts, do you think that Emacs' choice to be a comprehensive environment is the right choice for 2010 and the future?  Are there particular peripheral features that are still at or ahead of their time compared to alternatives?


问:
In simple words what are are the purposes of abstract classes and/or interfaces?
I have to explain to some students the use of abstract classes and interfaces, as I have a very tecnical background, I would like to know if you would help me to define an easy explanation for junior.

Simple definition:

What are the purposes of abstract classes, interfaces, and what is the difference between the two ?

When is it appropriate to use one instead of the other?

Thanks.

答:
I'll see if I can do this with generic terminology without too much hand-waving.

An interface is like a contract. It says that a class which implements the interface agrees to implement all of the functions declared (as signatures only; no function definition) by that interface. The class may do so in any way it chooses, and provide any other functionality, as long as it implements each one of the declared functions. An interface is useful when you want to be able to use some common functionality of otherwise unrelated classes- they share no implementation details, only the function signatures. In C#, function declarations within an interface are implicitly pure virtual.

An abstract class is a partially defined class that cannot be instantiated. It (usually) includes some implementation, but leaves some functions as pure virtual- declared only by their signature. Pure virtual functions are not defined in the class that declares them, so they must be implemented by a subclass (unless it too is an abstract class). Only a subclass which defines all of the pure virtual functions can be instantiated. The purpose of an abstract class is to define some common behavior that can be inherited by multiple subclasses, without implementing the entire class. In C#, the abstract keyword designates both an abstract class and a pure virtual method.

In practical terms, the difference between the two is that an interface defines only pure virtual functions, while an abstract class may also include concrete functions, members, or any other aspect of a class.


答:
I had experience participating in a "SCRUM" team with several employers. It appears to me that the managers take out the "daily scrum meeting" as the main point of SCRUM, and set it as the goal, instead of having it for what it is: a mean to achieve more effective development cycle.

Very quickly the 15 minutes meetings became 45 minutes meetings, the updates were ineffective because people would be busy yawning and thinking "when can we go already" instead of listening to others, and it would also break people's routines (I, for example, am an owl person, and getting to work at 9AM for this stupid meeting every day is a good enough reason for me to quit the job).

When managers take some idea which may be good if applied correctly, and take it to the extreme - they get the exact opposite of the results they expected. I personally think that the more meetings I participate in - the less work I'm doing. I have 2 regular meetings a week in my calendar and I usually skip one of them. Meetings are for managers, leave the developers to do their jobs.

I'm sure there will be plenty of SCRUM enthusiasts that will say "But it's so wonderful" - well, save it, I've heard it all.

Title: Why and for what reasons developers may not like "daily scrum"?

Body:
There are advantages in holding daily scrum, like:

Team get coordinated with each other

Everyone knows what amount of task has been done

Burndown chart gets more and more complete

Task board is updated

It doesn't last that much, 15 minutes won't kill anybody

However, recently (after 6 months of implementing and using scrum), I feel like that our developers don't like scrum daily that much anymore. People just update the task board, without explaining enough and it seems that  they're bored of it. I see that when for any reason, we don't hold it, they kind'of become extra-happy.

I just don't know what could be wrong with this. Are there any reasons mentioned somewhere for disadvantages the "daily scrum" can have for a team? What could be the reasons for developers getting tired of daily scrum?


答:
I won't take any of them.

A good syntax is useless if the programmer is not good at problem solving. And a poor syntax for a given language means the candidate does not feel himself comfortable with that particular language, maybe for a lack of direct experience.

Anyway, logic is far more important than syntax.


答:
Emacs could be an OS for you if you are willing to learn Lisp and write your own features that suits your needs.

But nowadays you can find everything you need in other tools made by other great people. Those people made those tools because they felt they needed them, just like you who will use them. Since many of them are open-source, there is a community which will make them better and better, with all the functionalities you need.

Trying to enhance Emacs is hard because you have to learn Lisp. Even existing plugins are getting older and older. Take language-modes for example, common languages like JS and PHP are hardly supported even for syntax highlighting. The best mode you could find for them is simply not enough.

Emacs is a great tool in the right hands, and for the right tasks. But there are better tools for specified tasks, and you should definitely use these instead.

Title: Emacs-as-OS: obsolete?


答: A junior assistant programmer or even a software tool might be able to find and fix bad syntax if the logic is good.  Bad logic... any fix is much less assured.  All programmers will screw up.  I would pick the one who's screw-ups are easier to spot and fix.</p>