答:
IMHO, it would be better if the language/compiler forced to some extent programmers to write more elegant code.

No one is forcing anyone to use C++ in the first place. If the language doesn't suit you then use a different one - there are many languages billed as "C++ without C".

The C++ design philosophy is to let the programmer decide. If they want to shoot their self in the foot then let them. This allows many bad things to be done, but also allows a great deal of flexibility. For instance, it is unlikely that Boost could be written in a language like Java as it takes advantage of language features and practices commonly shunned. It's also unlikely that C++ would grow as large as it has today - having access to the vast C library is a huge plus, take it or leave it.

C++'s compatibility with C is definitely one of it's weakest points, but also keep in mind that it's one of its greatest.

I'm going to add in a wonderful quote by Jon Purdy which I feel is extremely relevant:

It all comes down to pragmatism versus elegance, and for me, despite my obsession with precise, beautiful code, writing an ugly program that works is better than writing a beautiful program that does nothing.

Removing the hybrid may improve the elegance, but it hinders the capability.

Title: Why is C++ still "hybrid"


问:
Is there a drawback in defining multiple small DRY classes, instead of bigger more repetitive classes?
I read some articles and it seems that using multiple classes in CSS is encouraged.
I am curious to find out if there is a maximum number of classes an element can have before this multiple class solution loses its benefits. (It may become a speed matter of some sort)

For example I have a project which uses 4 types of fonts, 4 types of font sizes, 4 type of font colours and so on. Is it better to divide these styles in very small classes and assign them to different classes or just try to handle the code on bigger chunks, in which case the style file will be obviously bigger and not DRY.

I believe that besides a little more work and the code becoming a little more difficult to follow there should not be any other major drawbacks. Am I right?

答:
It may make sense to break the CSS into function specific sections; font, font size, color, etc.  Then assign the values to the appropriate containers.  You can specify multiple selectors for the same CSS definition. It would be possible to have 4 font definitions preceded by the appropriate selector list.  This moves you towards DRY.  Don't go overboard on function specific breakdowns, and combine them if it is appropriate.

Use function based names for classes rather than descriptive names.  Sidebar and content are better names than small and normal.

It is also common to clear or reset some values that different browsers default differently.  Consider carefully whether to override things like link behavior in text blocks.

Setting four as an upper limit then number of variations of any factor is a good starting point.  Font size might the exception.  Because you can have four colors or fonts shouldn't mean you must have four.  If one or two or three is the appropriate variety use it.  Two fonts is often enough.

ContentLicense: CC BY-SA 3.0


问:
Should I use the Date type in JAX-RS @PathParam?
This is what I'm thinking about doing on a JEE Glassfish server using Jersey.

```<code>@GET
@Path("/{name}/{date}")
public String getMessages(@PathParam("name") String name, @PathParam("date") Date date)
</code>```

I like the idea of being able to tell people consuming this RESTful webservice that "The date here is anything that works with the Date class in Java". That's pretty simple from the standpoint that they can just look at the Date spec, and they'll already have a working model that they can test with.

The problem that I'm worried about is that when I do this, JAX-RS is not very nice when Date() doesn't like what it gets in the constructor. Since Date() throws an error if it can't parse what it's given (like if you pass it the string "today" instead of a real date), the JEE server returns a 404 error.

Is this a good practice? Is there a better way to do this that I'm not thinking of?

答:
Who will use your service? Will they bother to lookup the specification of the Date class and figure out what kind of strings it will parse? I wouldn't, even if being a Java programmer I would know where to look ;-)

I think you should first tell your users what your URIs will look like, e.g.

```<code>.../your-resource-name/yyyy-MM-dd
</code>```

and then look for a way to have Jersey help you in parsing whatever date format you chose. That could mean using a Date parameter type and maybe specifying a regular expression in your @Path annotation, like

```<code>@Path(/{name}/{date: [0-9][0-9][0-9][0-9]-[0-1][0-9]-[0-3][0-9]/)
</code>```

or using some other class capable of parsing a date in your format. How to handle URIs that don't match the spec you give to your users is yet another thing you should decide how to handle independently of any of the above (return a default resource? return a 404 error?).

Body:
Who will use your service? Will they bother to lookup the specification of the Date class and figure out what kind of strings it will parse? I wouldn't, even if being a Java programmer I would know where to look ;-)

I think you should first tell your users what your URIs will look like, e.g.

.../your-resource-name/yyyy-MM-dd

and then look for a way to have Jersey help you in parsing whatever date format you chose. That could mean using a Date parameter type and maybe specifying a regular expression in your @Path annotation, like

@Path(/{name}/{date: [0-9][0-9][0-9][0-9]-[0-1][0-9]-[0-3][0-9]/)

or using some other class capable of parsing a date in your format. How to handle URIs that don't match the spec you give to your users is yet another thing you should decide how to handle independently of any of the above (return a default resource? return a 404 error?).


问:
API access question
FIRST, THE SCENARIO

We have an internal system that is effectively split into 2 very separate parts across 2 sub-domains, our back-end administrative system for internal access only we will call this admin.example.com and our public-facing interface for customers via our website - lets call this www.example.com/customers

We have built a series of APIs with PHP in the back-end system for the public interface to access, the APIs are split into multiple files based around the type of activity that is being performed and are also used in the admin interface, these are held in admin.example.com/apis/activity_api.php we have no problems here.

We also have API keys that are in-use, 1 for the front-end and one for the back-end so we can determine access levels without thinking about it.

SECOND, THE ISSUE

Now you know the structure of the application here is the issue, we are using jQuery AJAX to call the APIs but I don't like placing the API keys here as they are publicly visible and anyone with a little programming knowledge will be able to pull a huge range of data, at the same time we need to use them.

Note that the issue is only in the public interface.

What I am thinking of doing is calling a connecting script in PHP with AJAX that is stored locally on our public facing server, this would do a few things

Check the referrer, if it comes from example.com/customers/ or www.example.com/customers/ it continues, if not the request is killed with an unauthorized error

Gets the variables posted by the AJAX requests

Restructures the variables for the API (e.g. receives $_GET['request'] then reconstructs as $_GET['req'])

Adds the API key that is held as a variable within the PHP to the string

Uses file_get_contents() to make the actual request to the API, this would in turn populate the connecting PHP script with the required returned API data to the site

My questions are

Have I missed anything in this concept?

Are there any flaws that haven't been thought about?

Are there any compelling reasons why this type of structure should not be used?

I appreciate the input!

WHAT I HAVE DONE

I really want to thank you guys for your help and comments on this, you have pointed out what I missed and that was the purpose of posting the question in the first place. You also helped me spot the obvious weaknesses.

I have just written an algorithm that has taken into account HMAC principles. As with anything in this space there is room for unauthorized access but I believe my algorithm minimizes it.

The basic process we're going with is as follows

2 keys have been created, a private and public key

The public key is hashed first

A base calculation is carried out on part of the current time stamp

2 random keys for the get request are generated that will be used to transport the access keys, to determine the request keys a mathematical calculation is carried out on the base calculation in step 3, the result is then split into 2 parts, the 2 parts are verified as unique and converted to the final values, 1 part belongs to the public access key and the other to the private access key key

9 unique public values, plus the private access key issued are then taken, they are re-ordered based on a final calculation on the base value in step 3 creating a "signature" so to speak

The signature is then hashed and assigned to the private get key generated in step 4

On a quick calculation and basic testing, each request will be valid for approximately 27 seconds (give or take a few milliseconds) - enough time to process everything needed but not enough for much more. As the calculations are fairly basic the server load hasn't gone up an inch - I have only tested with 10 connections per second for 5 minutes however, I am going to run a series of load tests on it over the next 24-hours that will range from 20 request per second to 400 requests per second and compare with load test results taken last week.

So what my new algorithm does in a nutshell is disguises the public and private keys by hashing both - however after time the public access key will be obvious unless I assign an algorithm to randomize it, it assigns both access keys random get request keys and has a short validity time based on the request. It doesn't need to store any data in cookies or sessions. In addition, with exception to the login API, all requests are going via a PHP connector that requires the user to be logged in.

I spent more time explaining what I'm doing than actually creating it!

Thanks again for your help guys, it helped me open my eyes a bit more and reminded me about what I had forgotten.

答:
This is straight off the top of my head, but....

On the admin side, make a key generator that produces a guid and stores it, along with an expiration timestamp.

Make it so only your PHP from the web server side can access it. Since the PHP doesn't come to the browser, it's not super horrible to hard-code access creds for that.

The web server hits the admin, gets a new key, and statically embeds that in the javascript coming to the page.

The javascript then uses that key to authorize in its time window for requests. You need a way to notice when it's timed out and poke the server to create a new request.

At the very least, your window of opportunity for automated suckage is closed. This may not be much better than security through obfuscation, though.

Title: API access question


问:
Why is C++ still "hybrid"
On a related question, it has been clarified why C++ is not compatible with C in many aspects. However C++ is still a "hybrid"* language. And unfortunately, many programmers still consider C++ as a "C with streams and built-in strings". That results in really bad written code, that it's neither C++ nor C. IMHO, it would be better if the language/compiler forced to some extent programmers to write more elegant code. So is there a rationale for keeping modern C++ (for instance C++0x and future versions) hybrid?

* By hybrid I mean that it's up to the programmer to decide if he/she will use: standard strings and streams, classes, namespaces other than the default, etc.

答:
C++ is a hybrid not because it allows one to write C-style code, but because it supports several programming paradigms, such as procedural, object-oriented, and generic.  C++ does not force you into one way of doing things, and that is its strength, because different problems can be solved more easily using different paradigms.

IMHO, it would be better if the language/compiler forced to some extent programmers to write more elegant code.

Then you first have to define what elegant means.  Then you would have to see if your definition of elegant is appropriate to all the problem domains and platforms for which C++ is used.  A coding style that is elegant for writing a word processor for Windows might be completely unsuited for writing an embedded system.

Consider writing C++ code to run on a DSP.  First, the C++ compiler for that DSP may simply not support certain C++ features, like streams.  Second, you are severely constrained by the CPU speed, and possibly memory, so some C++ features may simply kill your performance.  For example you may have to avoid virtual functions for the sake of speed. Such considerations would radically change your programming style, compared to what you would use on a PC, and C++ allows that.

To summarize, C++ is a huge and complicated language with lots of features.  There are many reasons why any subset of those features may not be applicable to a particular project: speed, portability, compiler support, or even programmer experience and familiarity. For that reason for the language to force the developer to use certain features as opposed to others for any given task is a bad idea. Think of Java, where the language mandates that every function must be a method of a class. There are so many cases when creating a class just to wrap a method is awkward and unnecessary, and yet you have to do it because the language forces you to.

Title: Why is C++ still "hybrid"


答:
C++ has no "one true way"; every approach has strengths and weaknesses. The solution can be written a hundred different ways.

You as a software developer have to decide which approach is best for the task at hand.

Title: Why is C++ still "hybrid"

Body:
On a related question, it has been clarified why C++ is not compatible with C in many aspects. However C++ is still a "hybrid"* language. And unfortunately, many programmers still consider C++ as a "C with streams and built-in strings". That results in really bad written code, that it's neither C++ nor C. IMHO, it would be better if the language/compiler forced to some extent programmers to write more elegant code. So is there a rationale for keeping modern C++ (for instance C++0x and future versions) hybrid?

* By hybrid I mean that it's up to the programmer to decide if he/she will use: standard strings and streams, classes, namespaces other than the default, etc.


答:
If the committee were to attempt to force people to use (somebody's notion of) a more elegant language, it would probably be ignored. People would continue to do what they want, and compiler vendors would follow the market (but compiler vendors have enough representation on the committee to prevent this).

Much of what you're advocating is really a matter of judgement, based on the problem domain anyway. There are lots of small programs that just don't need (for one example) namespaces. Trying to force me to use a namespace when I'm writing a 30-line text filter would be foolish and arrogant. Even if you decided it would only apply when more than X lines of code, or Y functions, or whatever were involved, it would still generally be counterproductive. Namespaces were designed for a reason, to prevent/cure specific problems. Attempting to force their use in the absence of those problems accomplishes nothing useful for anybody.

At the same time, I think it's worth noting that quite a few people really do spend a lot of time and effort trying to not only enable elegance in C++, but to teach and lead people to use those capabilities to write better code (e.g., many Boost contributors). As such, the people who continue to insist on writing their code as "C with classes" are pretty much ignoring what's out there anyway. I think they'd be just as comfortable ignoring new compilers as they are ignoring everything that's been learned about how to use C++ over the last decade or more (e.g., Modern C++ Design was published 11 years ago now -- but most of the people you're talking about apparently haven't heard of it yet, much less read or understood even its simplest parts).

Title: Why is C++ still "hybrid"


问:
What are proven advantages of tools like GWT over pure JavaScript frameworks?
GWT is a software stack that translates Java code and a sub-set of the Java Runtime's class library to JavaScript code.

In comparison with JavaScript toolkits, GWT can seem alienating, by nature and by usage, and overly complex to do even simple things, taking away much of the fine-grained control you'd have by using JavaScript directly.

Why would a web-developer choose to use a tool like GWT, which uses a language originally not targeted for the web, instead of using pure JavaScript and JavaScript frameworks and toolkits?

Is it measurably better, and based on what criteria?

答:
Batteries Included

Java's Tooling

It is just awesome:

IDEs: even if some IDEs support JavaScript, the level of support just doesn't compare. Try to refactor JavaScript code on large codebases (say, 40K+ LOC) and weep.

Unit-Testing: though that picked up over the last few years, it's also way more mature in the Java world.

Continuous Integration and Continuous Inspection

Documentation Generation: Sure you have JSDoc and a few others

Static-typing

It catches bugs early. (Google Closure address that a bit while keeping the developer in the JavaScript world, if you prefer).

Optimized JavaScript

GWT writes faster and more compact JavaScript than you (for large applications),
and allows you to determine what gets sent to the client arguably more easily than with equivalent full JS solutions.

Architecture

It provides a good separation of concerns for large applications, with decent MVC or MVP architectures already pre-baked at your finger-tips.

Decent Library

GWT provides interesting libraries, and makes it easy (well, easier) to build I18N-enabled applications with dynamic bundle loading.

Unit-Testing

Using JUnit from within Eclipse IDE and from the command-line. This relates to my first point. You could very well also use some of Java's code quality tools on a GWT project (for source checks, not bytecode checks, as there isn't any).

It's All About YOU!!

GWT isn't for everybody. It makes some people more productive and gives a good tool for non-JS developers to build professional web-apps with dynamic front-ends without touching (too much) JavaScript. But if it doesn't work for you, just use something else.

If you want most of the above but you just don't want Java, maybe look at Google Closure, or the Dojo Toolkit.

Was a Good Idea at the Time: History Matters!!

The JavaScript world (and web front-end technologies in general) is extremely active these days, so things are looking up. But only a few years back, things were not so bright. LESS/SASS were not that popular, jQuery was not yet the de-factory JS library, JavaScript libraries weren't spawned every other week, and tooling wasn't that great in general.

But, there already was a growing demand for professional and large web-applications with dynamic front-ends, so there was a gap to fill to make developers more productive. JavaScript has a great many pitfalls and oddities that you need to be aware of, and maybe it's just better to not even need to care about them. Hence the niche for tools like GWT.

Since then, others have appeared (CoffeeScript comes to mind, Dart is on its way, but also large JavaScript frameworks, the revolution of server-side JS with Node.JS and others, and a strong comeback for JavaScript as "good enough" all-around language to be used not only on the client-side but also in other parts of your business stack.

Additional Notes

With Regard to your Original (Now Edited) Question About the Use of Firebug

You can debug GWT code with Firebug of course, but ideally you would debug it directly from the Eclipse IDE's debugger, which now provides live code debugging support.

However, Firebug it still usable, though you need to keep in mind that GWT generates optimized and compressed JavaScript, which may not be easy to debug as is.

With Regard to your Original (Now Edited) Question About CSS

Yes, you still need to write CSS code yourself, of course. You couple your GWT project with other tools though (like SASS), more or less easily.

It's Just a Tool!

Don't mistake GWT for what it's not: you don't write Java code to be run directly on the client side as Java bytecode. You write code in the Java language, which is then translated to JavaScript for efficiency and to allow you to use a higher-level language (or, at least, that's how it's meant to be seen).

Arguably, Java and JavaScript could be regarded as comparable in terms of abstraction levels. However, Java comes with some advantages (detailed above), hence the advantage in reaping the benefits of existing tools without the need to re-write them. Google's developers just had the clever idea of making it possible to reuse existing Java-oriented tools, but to in effect develop JavaScript applications.

Additionally, they solve another issue, which was the often cumbersome managed of dual-language web-applications where the JavaScript and the Java code was treated separately. The use of GWT allows a certain level of convergence for both sides of the development process.

Further Reading:

What are you thoughts on GWT?

For JavaScript stacks, look at Combinations of JavaScript/CSS/HTML Frameworks


问:
Are code reviews necessary for junior developers?
I've worked at two companies, who each had a different methodology when it came to code reviews:

In the first company, a code review was conducted by the team leaders and was required after the completion of every module.

However, in the second company, team leaders weren't required to conduct any code reviews, and just checked for functionality and design issues.

So I am confused. Is the code review process really needed? If it is, why? And if it isn't, why not?

答: Agile guy would say: "You don't need a code review, just do pair programming and write good tests" :)</p>

ContentLicense: CC BY-SA 2.5


问:
Is it considered best practice to dynamically bind return types from the Entity context?
```<code>MyDbEntities context = new MyDbEntities();
var result = context.StoredProcedureName(userId);
</code>```

In the situation above, is it considered best practice to use var or ObjectResult<ComplexType>?

答:
Generally, if you can't tell the return type by reading the line in question (or another, very nearby line), you should use the explicit type. This will make the readability of your code much better.

var should be used only when the implicit type is discoverable in the same line of code or very nearby.

In your example, you should really use ObjectResult<ComplexType>:

```<code>ObjectResult<ComplexType> result = context.StoredProcedureName(userId);
</code>```

These cases are ok for var, because the types are easily discernible:

```<code>var user = context.Users.First(x => x.Id == userId);
</code>```

or

```<code>var users = context.Users.Where(x => x.LastName == lastName);
foreach(var user in users)
{
  //do stuff
}
</code>```

Body:
Generally, if you can't tell the return type by reading the line in question (or another, very nearby line), you should use the explicit type. This will make the readability of your code much better.

var should be used only when the implicit type is discoverable in the same line of code or very nearby.

In your example, you should really use ObjectResult<ComplexType>:

ObjectResult<ComplexType> result = context.StoredProcedureName(userId);

These cases are ok for var, because the types are easily discernible:

var user = context.Users.First(x => x.Id == userId);

or

var users = context.Users.Where(x => x.LastName == lastName);
foreach(var user in users)
{
  //do stuff
}


答:
I would have no problem using var if your method name and/or variable name clearly indicated what was being returned.  Readability is the key.

```<code>var foos = context.GetUnallocatedFoosForUser(userId);
</code>```

For what it's worth, when you use var, you're not dynamically binding anything.  The compiler AND the IDE know what type (even if it's just object) that you're dealing with here.  The var keyword is just a short-hand for "use whatever type is on the right hand side."

It would be different if you used dynamic, but that's a very different kind of question and not really applicable in this situation.

Title: Is it considered best practice to dynamically bind return types from the Entity context?

Body:
```<code>MyDbEntities context = new MyDbEntities();
var result = context.StoredProcedureName(userId);
</code>```

In the situation above, is it considered best practice to use var or ObjectResult<ComplexType>?

Body:
I would have no problem using var if your method name and/or variable name clearly indicated what was being returned.  Readability is the key.

var foos = context.GetUnallocatedFoosForUser(userId);

For what it's worth, when you use var, you're not dynamically binding anything.  The compiler AND the IDE know what type (even if it's just object) that you're dealing with here.  The var keyword is just a short-hand for "use whatever type is on the right hand side."

It would be different if you used dynamic, but that's a very different kind of question and not really applicable in this situation.


答:
Sounds like a bad idea. For one thing, the Date constructor that you'd be relying on has been deprecated since Java 1.1 in favor of DateFormat.parseDate(), precisely because it's unclear how strings should be parsed into dates, as the rules are different for different localities.

My recommendation would be to stick with a specific format, preferably the internationally understood yyyy-MM-dd, and use a DateFormat to parse the date from a string inside your service, which makes it clear how to consume the web service, and allows you to follow whatever the standard convention for returning error messages is for your web services when something goes wrong.

Title: Should I use the Date type in JAX-RS @PathParam?

Body:
This is what I'm thinking about doing on a JEE Glassfish server using Jersey.

```<code>@GET
@Path("/{name}/{date}")
public String getMessages(@PathParam("name") String name, @PathParam("date") Date date)
</code>```

I like the idea of being able to tell people consuming this RESTful webservice that "The date here is anything that works with the Date class in Java". That's pretty simple from the standpoint that they can just look at the Date spec, and they'll already have a working model that they can test with.

The problem that I'm worried about is that when I do this, JAX-RS is not very nice when Date() doesn't like what it gets in the constructor. Since Date() throws an error if it can't parse what it's given (like if you pass it the string "today" instead of a real date), the JEE server returns a 404 error.

Is this a good practice? Is there a better way to do this that I'm not thinking of?


问:
Converting ANTLR AST to Java bytecode using ASM
I am currently trying to write my own compiler, targeting the JVM.

I have completed the parsing step using Java classes generated by ANTLR, and have an AST of the source code to work from (An ANTLR "CommonTree", specifically). I am using ASM to simplify the generating of the bytecode.

Could anyone give a broad overview of how to convert this AST to bytecode?

My current strategy is to explore down the tree, generating different code depending on the current node (using "Tree.getType()").

The problem is that I can only recognise tokens from my lexer this way, rather than more complex patterns from the parser.

Is there something I am missing, or am I simply approaching this wrong?

答:
This is simply too large a topic to cover in a Q/A forum.  You need to buy / borrow and read a textbook on compiler writing that has good coverage of code generation.

The problem is that I can only recognise tokens from my lexer this way, rather than more complex patterns from the parser.

I don't understand this.  Do you mean that you don't have a symbol table?  If not, you'll need one.  A good textbook will explain this concept and how to implement it.

If someone would care to suggest an up-to-date textbook, feel free.  (I have a copy of the Dragon Book ... but it is pretty dated.)


问:
How to develop line-of-business tablet apps as a .NET developer?
My company has a lot of experience in .NET development, and one of our products in an ERP system. Recently, a customer asked us if we could provide a tablet interface to that system, i.e., a software that allows the customer to view product information and create orders on a tablet.

Of course, we are not thrilled about the idea of investing a lot of time and money into learning Objective-C, purchasing Mac development workstations, paying fees to Apple, etc. just for this one project (we might be able to sell the app to a few additional customers afterwards, but the market is very small, since it would only be useful for existing customers of our ERP system).

So, what should we do? As far as I can see, we have the following options:

Write a "plain old Windows application" (WPF) and run it on a Windows 7 tablet, such as the Samsung Slate or Acer Iconia.

Drawbacks: Heavy, expensive devices with short running time (as compared to "real" tablets).

Wait for Windows 8 ARM-based tablets and write a Metro (WinRT) app.

Drawbacks: Wait for at least one year; it's unclear whether Windows 8 ARM will support installation of custom B2B apps without going through the app store.

Use mono for Android and write a .NET app for Android.

Drawbacks: Yet another UI library (different from WPF and Silverlight); some providers disallow sideloading of apps.

So far, options 1 and 3 seem to be the most realistic. Did I miss any obvious drawbacks or advantages? Is there another option that I haven't considered yet? Have you been in a similar situation and (successfully) chosen one particular option?

答: Any Windows application will mean that you are tied to MS. Also, Silverlight and iOS/IE 10 don't go together well. Go for HTML 5 and JavaScript with Web Services and/or JQuery. Third party tools such as Telerik-Kendo UI should make your GUI cool enough for LOB App. Dot Net could only be of value on the server side.</p>


问:
Software development project inception phase
Currently our team develops Web Applications and now we are going to Windows Forms applications.

I have created the inception phase for our Windows Forms project structure.

eg:

```
ApplicationSolution

--> Security Project(Login Authentication)

         a. Users will be registered with different applications in our application database.
           eg: ProjectApplicationId|ProjectName        | UserId
               1                   |ProjectApplication1| user
               2                   |ProjectApplication2| user

         b. Execute Application (Start)
         c. On Security dialog, application automatically get the userid of the user and see all the application it is registered using System.Security.Principal.WindowsIdentity.GetCurrent()
           eg: Prototype
              Welcome User! Please Choose Appliations you are registered on below:
                                 ProjectApplication1 <--this will be a dropdown
                                 ProjectApplication2
              Password: [*********************]
              [Access Application Button]
         d. User selects the application with its password
         e. If the password is incorrect (application.exit()) else execute Selected Application
             eg: ProjectApplication1 is selected then execute ProjectApplication1

--> ProjectApplication1

--> ProjectApplication2

--> Many to come ++

        if ProjectApplications has been closed then restart security Application.
```

My questions on this use case:

Is my use case possible?

Can you give me any recommendations ?

Currently we use setup and deployment to create installer in each Windows Forms application.

答:
I see the following with your Use Case:

You have skipped the details for entering userid and the associated validations.

You are getting into details such as the display of the message "welcome user..." - This kind of details is best explored on a GUI prototype not on the use case.

Things that are not clear:

c1 - How does the application start - There is no step showing this.

c2 - Do you assume that the applications displayed are for this userid? If so, your use case should say that.

c3 - Does the user has to enter an Password?

c4 - How many times could the user enter his/her credentials?

c5 - What if the user wants to exit at some point, is it possible - How?


问:
C++ Renaissance - marketing slogan?

Possible Duplicate:

  What does the latest “C++ Renaissance” mean?

Lately, I hear a lot about C++ Renaissance. What is that?

C++ is currently undergoing a renaissance. This means that, by definition, the language, compilers and compositional tooling are evolving and coalescing into a state that maximizes native developer efficiency, productivity, and creativity across hardware and software domains.

I agree that C++ needs a lot of improvements, mainly, because it was updated in Neolithic Age (98,03).
What really bugs me is the Build conf. They've showed a few metro style apps written in C++ and XAML - like RSS reader or Piano.

I have a feeling that C++ is an overkill for this kind of apps and only case when I see the advantage is battery power, but is it true? C# as well as C++ calls WinRT which is native and C# has only tiny runtime overhead.

Can someone provide case study or hard data where use C++ in windows 8?

I think it will be status quo (games, servers, OSes, databases, apps like Photoshop will be C++ and other client apps run .Net) and renaissance is just a marketing slogan.

答:
Can someone provide case study or hard data where use C++ in windows 8?

Well, the OS is written in C++.

The quick answer is that nobody with half a brain wants to design a commercial app that runs 10x slower and drains more battery than competing apps.

OwnerDisplayName: lukas

Title: C++ Renaissance - marketing slogan?


问:
Modularity vs Single class simplicity
I have been part of the organization I work in for the past year and a half or so. The company basically writes Perl code and they have large amounts of legacy code which originally prevented the company from moving forward with any code changes. My first observation with the existing code was non existence of Modularity.

Over the time I worked here I, with the help of a few (who left the company), did a lot of hardwork Modularizing all the core sections of the application. I believe that we now have about 70% of the core systems modularized, coherent and layered. At this point in time I am accused of complicating the system design and everything I try to do is sort of looked at with suspicion.

To design these systems I applied all the best design approaches(patterns) and methodologies(SOLID) available or known to me. When I wrote it, it was all appreciated but now the developers want to revert back to what they believe as simpler methodologies(which basically involves having large single classes, doing 100's of things). I still do not believe that those approaches are actually going to lead to simpler design but no one is actually ready to listen.

To give an example, our code basically loads a bunch of files during its lifetime. Traditionally the class handled a lot of things like loading the file, repeatedly checking if the file has changed, is the right version of the file loaded etc. We also load a different set of files for test cases to ensure that it is working fine. All this was done very un organized fashion earlier. Every one created their own version of the file. There were lots of versions of these files and they were un manageable. I introduced a subsystem that will load you the right file(do the version verifications) given a name and a configuration that will tell all the versions of the file available. It eventually ensured that only two to three versions of the files are used across all the test cases. It basically follows a facade and factory pattern where the loader will create the right file object, which will have interface to load, save and should_reload. It was eventually even used to load contents from CouchDB as they only represent a document. This is now too complicated for the developers and no one really reads the code or the documentation I wrote. I do agree that going back to our old system will remove one sub system but will bring back the problem of un manageable number of files.

At this juncture I find myself quite unsure of all the things I have learnt. I find myself not really interested in suggesting any improvements as my solution will only be accused of being too complicated.

What do you think I can do at this point in time?

答:
Economics - that's what you MUST do and COMMUNICATE. Let's say they do it they way they want to. And then we have your way. What are the benefits?

Can you 'break down' the benefits? (Keep asking so-what until you hit the end benefit). Now, can you quantify the benefits and convert it to a dollar-$ value? (if it's worth it, it should be quantifiable - if you are confused pick up Doug Hubbard's "How to Measure Anything" :)

Now, take the differences to the management. Show them how what you did helped them be well off, using economics (that's all they'll want to see/hear at this point owing to your situation). Use numbers: cost saved/earned, revenue estimated, future savings, operational efficiencies etc., whatever it is that you think is/was the benefit of your design. Create a simple business case and SHOW it to them. Keep it believable please.

Your managers/bosses should see this with ease and be more confident rather than just "technically better claims." If they can't you are in the wrong company - they can't understand business economics!!

(You may want to look at Steve Tockey's excellent book - "Maximizing return on software" - it's all about showing the economics of anything technical)

Best of luck!

Title: Modularity vs Single class simplicity


答:
It's not measurably better.

For everyday use, consider jQuery, AmpleSDK, or some html5 polyfill.

GWT has a lot of overhead: actual and conceptual.

Might be useful if you have a java app or some server side java code to port to a web frontend.

Title: What are proven advantages of tools like GWT over pure JavaScript frameworks?

Body:
GWT is a software stack that translates Java code and a sub-set of the Java Runtime's class library to JavaScript code.

In comparison with JavaScript toolkits, GWT can seem alienating, by nature and by usage, and overly complex to do even simple things, taking away much of the fine-grained control you'd have by using JavaScript directly.

Why would a web-developer choose to use a tool like GWT, which uses a language originally not targeted for the web, instead of using pure JavaScript and JavaScript frameworks and toolkits?

Is it measurably better, and based on what criteria?


答:
One thing that comes to mind is something I just read in Robert Martin's book: You learned design patterns and you learned solid principles. But all these things should not be applied blindly to any and all code just because you know them. Instead, they should be applied when the alternative would be more complicated than not applying them.

It's a pretty good book and he walks you through a bunch of examples of iterative, test drive development. Throughout the book there's a unifying message that says, keep the code simple, don't introduce extra abstraction layers and patterns. Instead, incrementally add features and converge towards known patterns when that proves to be the simplest solution.

Based on your post, it may have sounded like some of your software could have been considered as over-designed. At the same time I do not know what the skill level for the rest of your team is.  And unfortunately, I can easily imagine other people getting confused when they see 2 classes and an interface even if you were absolutely correct in suggesting them.

In my experience, there are definitely some programmers who do still believe that the goal of our job is to stitch together API calls using any number of control statements needed. And when you need to extend the code, you simply need more control statements. And what makes a good programmer is one that can navigate 600-line method and be able to make it 700 lines while introducing only 2 bugs. And if this is what they believe, you will have a very hard time convincing them otherwise, God knows I've tried.

I don't have a good answer for this type of situation.  My only advice would be to gain support of the project technical lead, or another senior developer that others look up to. Have some discussions and reflections on past code and see if you can identify what was done in the past that worked and that didn't. Once you have them on board with you, gain support of management so that the right people would have the capability of ensuring some level of design makes it into the product.

If you don't have that support, I guess you could either a) look for a different job/team or b) create a bubble of good code around you and try to work in isolation :)

Just remember that we apply patterns and SOLID not because we read about it, but because it IS THE SIMPLEST code we can possibly write. So if you practice this stuff, you should be able to code faster and produce higher quality code than your team mates.  Eventually others, including your management, will notice that.  If you find yourself producing "proper designs" but your tasks continuously take you twice as long as they would have otherwise, then you may be missing something (good design might take more time upfront, but you should expect to see a payback in very short future).

Title: Modularity vs Single class simplicity

Body:
I have been part of the organization I work in for the past year and a half or so. The company basically writes Perl code and they have large amounts of legacy code which originally prevented the company from moving forward with any code changes. My first observation with the existing code was non existence of Modularity.

Over the time I worked here I, with the help of a few (who left the company), did a lot of hardwork Modularizing all the core sections of the application. I believe that we now have about 70% of the core systems modularized, coherent and layered. At this point in time I am accused of complicating the system design and everything I try to do is sort of looked at with suspicion.

To design these systems I applied all the best design approaches(patterns) and methodologies(SOLID) available or known to me. When I wrote it, it was all appreciated but now the developers want to revert back to what they believe as simpler methodologies(which basically involves having large single classes, doing 100's of things). I still do not believe that those approaches are actually going to lead to simpler design but no one is actually ready to listen.

To give an example, our code basically loads a bunch of files during its lifetime. Traditionally the class handled a lot of things like loading the file, repeatedly checking if the file has changed, is the right version of the file loaded etc. We also load a different set of files for test cases to ensure that it is working fine. All this was done very un organized fashion earlier. Every one created their own version of the file. There were lots of versions of these files and they were un manageable. I introduced a subsystem that will load you the right file(do the version verifications) given a name and a configuration that will tell all the versions of the file available. It eventually ensured that only two to three versions of the files are used across all the test cases. It basically follows a facade and factory pattern where the loader will create the right file object, which will have interface to load, save and should_reload. It was eventually even used to load contents from CouchDB as they only represent a document. This is now too complicated for the developers and no one really reads the code or the documentation I wrote. I do agree that going back to our old system will remove one sub system but will bring back the problem of un manageable number of files.

At this juncture I find myself quite unsure of all the things I have learnt. I find myself not really interested in suggesting any improvements as my solution will only be accused of being too complicated.

What do you think I can do at this point in time?


问:
What can slow a developer down?
What things tend to slow a developer down?

Please try to refrain from posting answers that:

are slow now but useful in the feature. (TDD, Refactoring, ...)

list a distraction.

答:
Conversations of others

and noise in general

Many answers talk about context-switching and getting out of the zone, and noise, especially conversation, is one of those things that leads to those for me.

In my cubeworld, I'm surrounded by noise and conversation on all sides.  One row over, the mainframe team holds constant planning meetings in the cube row.  Sometimes, they'll meet with consultants in an office along the wall, and that tends to lead to loud hootin' and hollerin' and laughin' and I have to go over and ask them to close their doors.

On the other side, the web team conference table is on the other side of my west cube wall, so I am part of every meeting, like it or not.  There's also a printer on the other side of the south cube wall, and that's always good for chit-chat from people hanging out waiting for their printouts.

The immediate and obvious answer of "Can't you just get noise-canceling headphones" doesn't help when what you want is silence.

Sometimes for code reviews, I take my stack of papers to the lunchroom (at non-lunch times, of course), but there's a TV in there that's usually blaring.  I'll turn it off if no one is watching.  Otherwise, I'll go find an empty cube in an other department in another part of the building.

If you want your programmers to do the work they need to do, which is predominantly thinking and pondering and considering, they need an environment where they can do it.

Title: What can slow a developer down?


问:
MFC and WPF similarities
What are the similarities between MFC and WPF?

Is it worthy to learn MFC before WPF?

答:
MFC was a nice framework for its time.  It let you abstract the Win32 API, and made things much simpler to develop, especially when it came to GUI and MVC development.   I developed in it for several years, it was much nice than using straight Win32 api.

There is nothing particularly terrible about MFC.  Bad software can be written in any language.  And there certainly is a learning curve to MFC, as there is to any other language.  Add in a badly written application, and I can see confusion happening.

In fact as I've developed WinForms, WPF, etc, I've found the basic concepts of windows development really hasn't changed.  You still have buttons, dialog windows, events, threads, mutexes, etc, etc....

Title: MFC and WPF similarities


问:
Cron'ing PHP scripts that write to other files.
So the client I am working for right now is really big on load time speed, so we try to shave every micro second possible. We found a file the other day that was pulling some word press blogs and it was adding a solid second to the load time.

Now I didn't write that particular script and perhaps I can go optimize it later, but for now, what I did was make a script that writes the output of the wp script to another file, then I simply reference that file when we need it. We run a cron on the script I wrote so it checks the wp script every so often and outputs any updates if needed.

That obviously really made things faster but I just have never done it before so I am curious about it:

obviously we have a file with 777 permissions, what are my security concerns for this?

Is this a good strategy to cut down in the future when the processing doesn't have to be done at the time of load?

答:
you shouldn't have 777 permissions on that file. change the file to be owned by the user your apache (or whatever webserver you're using) is running (for example wwwrun.www on suse linux or www-data.www on ubuntu). after this you can give read and write permissions just to that user (644) - you don't need permissions for executing at all.

EDIT:

the commands to do this are

chown wwwrun.www myfile.txt to change the owning user (wwwrun) and user-group (www)

chmod 644 myfile.txt to change the permissions (6 = read/write for owner, 44 = just reading for everyone else)


问:
Would you allow your programmers to use Messenger and social networks like Facebook?
I had many bosses, each one had a different approach about allowing or not use of Windows Live Messenger, Facebook, and many other Internet sites.

Of course Internet is really needed to research about the best way to solve a specific task. Sometimes you could have a friend online, also a programmer, who knows better about something.

For some managers, internet access would slow down project progress, and on the other hand, allow people to interact and find out brand new solutions.

What would you do?

答: I think chat software can be very useful for passing code snippets and URLs around between programmers (and much more efficient than voice dictation). So some kind of messenger should definitely be allowed.</p>


问:
Trying to understand Single Responsiblity Principle
I'm having a difficult time understanding the Single Responsibility Principle.

What should I look for to evaluate the various sources of information on the matter?

What should I look for in examples explaining the principle?

答: Pluralsight has a course Principles of Object Oriented Design that covers SRP as the first topic in about 12 minutes. I believe you get a couple of hours of video for free, after that you need a subscription.


问:
How important is it to pick the best IDE for your programming language of choice?
As I learned some basic programming languages I came across tens of IDEs, and tens of compilers. Most people you ask will tell you "Go with that IDE or go with the best" etc, however they do not provide a proper statement as to why this is important. I understand a good IDE will provide you with functionalities to save time and money, such as debugging or quick-word-fill, but I doubt that's the whole reason a programmer picks a good IDE.

At school we work on old compilers (Money probably isn't the reason) because the theory "As long as you learn it's good" works.

The bottom-line question is: How important is it to pick the best IDE for your programming language? YOu have Eclipse for Java, C++, Python and more, but can't you simply use a different one? What difference does a good IDE to your programming skills or your programming time?

答:
The question even goes beyond the IDE, sometimes the tools that plug-in to the IDE make all the difference. Using a tool like ReSharper with Visual Studio can not only speed up your programmer, it can help you refactor and even learn the language. For example, it notices code that can be turned into LINQ and then will do it for you. It can also enforce coding standards.

One of the things that makes Eclipse so useful is that it is so extensible, it supports multiple languages, and plug in for source code control, static checking tools and even bug tracking tools. The Mylyn plugin  is an example of a very cool tool that can help you work more productively by yourself or with a team. Plus Eclipse runs on multiple platforms. The Eclipse CDT package is free so there's no excuse to use outdated compilers due to budgetary constraints.

Sometimes your IDE is picked for you based on what your target is, this is especially true in the embedded world.


问:
Is programming or computer science in general, all about algorithms?
As a grad student, I find it more and more common for prestigious companies (like Google, Facebook, Microsoft,...) to put algorithm questions in their test and interviews. A few startups I applied to also asked about algorithms. I wonder if algorithms fluency is the most important thing for software developer in those companies?

If the answer being yes, what are the best method or resources for one to learn & practice about algorithms effectively? I can't seem to get interested in solving seemingly too complicated problems found in most textbook or websites. Though easily understand basic algorithms (like quicksort, bubblesort,...), I find it immensely difficult to remember and reuse them later.

Thanks.

P/S: If you ask me what I like, it's building good softwares to solve users' problems innovatively. I suppose that does not necessarily mean the software has to be very complicated.

答:
Only programmers that work for those companies can really answer you question. The kinds of algorithms dealt with in say "Introduction to Algorithms" have probably played a part in 0.01% of my programming life over the past 25 years. When I need a data structure or a sort usually the supplied libraries or frameworks have what I need. When I need a super fast FFT I find something like the Intel Math lib rather than write one myself. However, I can how what they do at Google is way different than what I've done in my career. Skiena's book "The Algorithm Design Manual" was eye-opening because of the War stories he tells. You can tell he uses Algorithms in his job A LOT.

In my experience as an independent programming consultant, success has come from three things
1. Communicating effectively with clients
2. Writing code that works.
3. Managing Complexity

Doing just numbers 1 and 2 isn't enough. If code isn't maintainable (by someone other than the programmer(s) who wrote it, it's doomed.

Number 3 is the hardest programming skill to master. It requires thought be put into architecture, design and coding. It requires mastering refactoring. It requires an understanding of SOLID/DRY principles. If I had to hire a programmer who had read Intro to Algorithms and dedicated himself to mastering it or one that read The Pragmatic Programmer and dedicated himself to being one, I would hire the latter every time. (Not that they have to mutually exclusive).


答:
Instead of diving into the details of security authentification too soon, I would strongly recommend to focus on the "real" or "business" use cases first, and what kind of application system you have in mind (in terms of number of expected users, expected lifetime of the application, general security requirements depending on the types of data available, general platform considerations like Winforms vs. WPF etc.) Otherwise you take the risk of loosing yourself into unimportant details.

Analysing things like "authentification" first is most often a sign that you have not took enough time to understand the business domain and try start with those things where you don't need any understanding of the domain.

Title: Software development project inception phase

Body:
Currently our team develops Web Applications and now we are going to Windows Forms applications.

I have created the inception phase for our Windows Forms project structure.

eg:

```
ApplicationSolution

--> Security Project(Login Authentication)

         a. Users will be registered with different applications in our application database.
           eg: ProjectApplicationId|ProjectName        | UserId
               1                   |ProjectApplication1| user
               2                   |ProjectApplication2| user

         b. Execute Application (Start)
         c. On Security dialog, application automatically get the userid of the user and see all the application it is registered using System.Security.Principal.WindowsIdentity.GetCurrent()
           eg: Prototype
              Welcome User! Please Choose Appliations you are registered on below:
                                 ProjectApplication1 <--this will be a dropdown
                                 ProjectApplication2
              Password: [*********************]
              [Access Application Button]
         d. User selects the application with its password
         e. If the password is incorrect (application.exit()) else execute Selected Application
             eg: ProjectApplication1 is selected then execute ProjectApplication1

--> ProjectApplication1

--> ProjectApplication2

--> Many to come ++

        if ProjectApplications has been closed then restart security Application.
```

My questions on this use case:

Is my use case possible?

Can you give me any recommendations ?

Currently we use setup and deployment to create installer in each Windows Forms application.


答:
Even though you asked not to list distractions, they can be a big factor. Look at their work environment, check to see if they're being interrupted frequently or asked to do other things that aren't related to the project.

Sometimes, a developer might get stuck because they're doing something they've never done before, and they don't know where to look for help. If it's a small team or individual, it can be even more difficult. We tend to be somewhat prideful and dont like to admit when we dont know how to do things. Also, we dont like asking others for help. There's no easy way to get a developer to admit this, except maybe to ask if they can meet the deadline, or what they need to meet the deadline, and then hope they'll be honest. You may need to offer to bring in other help, or find someone that can help them.

Lack of clearly defined requirements, which leads to them having to figure things out or make decisions.

Title: What can slow a developer down?

Body:
What things tend to slow a developer down?

Please try to refrain from posting answers that:

are slow now but useful in the feature. (TDD, Refactoring, ...)

list a distraction.


答:
I've developed both desktop applications and web applications and mixture of both (dual interfaces Fat and Thin clients).

So long as you have a good client-server (database back end) architecture.

It should not matter what the front end is (web application, desktop application, mobile application).

After re-reading your question it makes no sense?

EDIT:

Ok, just re-re-read your question.

Basically just have a login screen, once the user logs in you simply store the ID in memory (think session ID).

The user is then presented with a screen that shows ALL Project Applications (that they have access to).

They can then click any any one to access it. Pretty straight forward.


问:
Right Tools For The Job? One Location vs Multiple?
I'm currently using Codebase for all my project management (where I'm learning Agile). I use it for tracking bugs, user stories (via tickets), wikis, files and git hosting.

However, I'm looking to improve on this and find some tools better suited to things like bug tracking, managing stories, git hosting, collaboration, client feedback etc.

I'm part of a small team of 3 or 4 developers.

Does anyone have any recommendations?

My initial thoughts based on research was:

Project Management: JIRA

Bug Tracking: JIRA

User Stories and Agile: Pivotal Tracker

Git hosting: JIRA

Storage: Dropbox

However it seems this is quite disjointed in that it could prove more work than its worth.

Appreciate any advice on the above or tools which you've used and found work great for small-medium teams and suit Agile.

My SPECIFIC requirements are:

Bug tracking, managing stories, git hosting, remote team collaboration, client feedback, time tracking, storage, build management, project lifecycle progression data...

I also found Assembla which seems excellent. One of my team members believes in "the right tool for the job" and that there is no single tool to manage all of this. I was hoping for a central location.

答:
In our company we are currently running a similar configuration to the one you have proposed, so I'll give my insights.

Last year we moved to JIRA to handle most of our development support requirements.  We have a distributed team across multiple countries, and we needed a strong set of support systems to keep our development running smoothly.

We love JIRA and it is very flexible, and it nearly met all of our needs.  The base Jira system handles issue tracking very well.  GreenHopper works awesomely for agile planning, and the integration with base JIRA works really well (issues can be estimated and have time tracked on them, which are reflected real time in burn down charts).  Bamboo can be used for deploys and automated testing.  The Confluence wikis are very powerful and are good for centralising documentation.  We can export articles as PDF if we need to distribute them externally, and they are very nicely formatted.

We were not as pleased with the VCS hosting, Crucible reviews and Fisheye.  Performance was very poor, and the interfaces were hard to use and cumbersome.  Recently we decided to move the code side of things over to GitHub and we have found what we believe is the best solution for us right now.  JIRA supports GitHub push notifications on commits, so commits can appear on tickets inside JIRA.  We also built command line tools for commenting and adding time to JIRA tickets, as well as creating pull requests in GitHub, so our developers can do a lot of things without leaving the command line.

We also use Google+ hangouts for meetings and collaboration, and we are very happy with this.  People can jump in in the web browser, and everyone can screen share, use a shared whiteboard and use Google docs inside the hangout.

We are currently very pleased with this solution and I would highly recommend it.

Issue tracking: JIRA]

Agile: GreenHopper (JIRA)

Wiki/Documentation: Confluence (JIRA)

Builds/Testing/Deploy: Bamboo (JIRA)

VCS hosting (git): GitHub (Private repos available, integrates with JIRA)

Code reviews: GitHub (Using pull requests)

Collaboration/meetings: Google+ hangouts


答:
From my experience, the best time/money saver is not the relevance of IDE to language but the relevance of IDE and language to YOU.

A C/vim master using vim to develop C is far more productive than a Java/Eclipse master using Emacs to develop Cobol.

That said, if you work in a team, it is worth considering using the same tools among the whole team. This makes cooperation easier when two people work on the same computer with an environment that both know well.

Moreover, some platforms ship with a dedicated IDE: Xcode on Mac for Objective-C/Cocoa development.

Title: How important is it to pick the best IDE for your programming language of choice?

Body:
As I learned some basic programming languages I came across tens of IDEs, and tens of compilers. Most people you ask will tell you "Go with that IDE or go with the best" etc, however they do not provide a proper statement as to why this is important. I understand a good IDE will provide you with functionalities to save time and money, such as debugging or quick-word-fill, but I doubt that's the whole reason a programmer picks a good IDE.

At school we work on old compilers (Money probably isn't the reason) because the theory "As long as you learn it's good" works.

The bottom-line question is: How important is it to pick the best IDE for your programming language? YOu have Eclipse for Java, C++, Python and more, but can't you simply use a different one? What difference does a good IDE to your programming skills or your programming time?


问:
In order traversal of M way Trees
If we have a 4 way tree such as the one shown below, and we do an in order traversal, what would the output of the in-order traversal be for an M-way tree?

In which order would the nodes be visited? When would the value in the node be processed (upon first visit or upon second visit)?

(As a concrete example, what would the step by step procedure for the in order traversal be for the example tree shown below?)

答:
There is no obvious in-order traversal for rose trees (m-way trees), unlike for pre- or post-order traversals, because while you clearly need to process the leftmost subtree first and the rightmost subtree last, it's not clear when you should process the current node.

I ended up saying "process the leftmost subtree, then the current node, then the remaining subtrees in order". When the rose tree's nodes all have two or less subtrees, that ends up with the same traversal as a binary tree's in-order traversal.

Assuming that each node in your diagram has an array value (I don't find your diagram very clear), the traversal I describe would yield [[2,5,6],[7,20,45],[9,12,17],[26,31,39],[46,53,71]].

Title: In order traversal of M way Trees


问:
choosing a functional language platform for a new project
I have been writing code for a few years now and I don't believe I can claim to have a complete knowledge in this job yet.

My experience primarily rolls around C# related areas with a decent knowledge on Silverlight and Asp .Net MVC as well. I tend to use Sql server and Postgres for normal RDBMS related tasks with Mybatis or LinqtoSql as ORM (and Cassandra as well for NoSql).

Given that background, I am looking to building a new project which is a normal application using database and user interface screens. It is considerably a big project which we plan to be rolled out as a product.

In recent times, I see a lot of noises being made about functional programming like Haskell and F#. I am wondering
   - if it is worth to build the new system using Haskell
   - or just stick to a regular application building model using Silverlight/Prism with a layering similar to onion architecture

I understand the benefit of staying with the same technology background as it is always good to work on a familiar technology.

I also heard that by moving towards a functional language like Haskell we get cleaner code, improved testability etc.,

Is it really worth considering a move to build new systems in Hasekll? Or it is yet to be proven in production environments?

Simply put would I be safe if I build the new project using Haskell and my preferred database or it is too risky at this point in time to choose Haskell.

Any help appreciated.

Edit: I have already viewed a few other threads like the following and a few more as well, but did not get a definitive answer.
Choosing a functional programming language

答:
Can't say anything about Haskell, because I didn't use it. But as a .NET developer I advise you taking a look on Nemerle if you are considering use of F#. Even though Nemerle is not supported by Visual Studio as good as F#, there is a perfect extension which solves all the problem with integration. Why do I recommend Nemerle?

It's written on .NET and for .NET platform.

It's a perfect functional language (even better than F# on the same platform).

It supports macros conception very well. So you can easily can extend the existing type system and even build your own DSL without making effort.

To be honest, I have to remind the main disadvantages of Nemerle which may also be applied to some other functional languages:

It can be rather difficult to find developers which know Nemerle (and Haskell/F#) for your project. At least it's much harder than to hire a 'regular' C# developer.

Nemerle (and Haskel) and some other languages are not well supported by .NET platform. So you can rely only on yourself and the community of the chosen language.


答:
Excessive paperwork

Having a dependency on someone who's never around (such as your boss - if you need to ask a question but he's always in meetings)

Inadequate tools & equipment.

People shoving their oar in for no reason (any UI-visible change is subject to this) or just arguing the toss about trivial stuff.

Broken coffee machine

Being assigned the wrong tasks

Title: What can slow a developer down?


答:
If you want to stick with .net use F#. From what I understand it is a really nice language and borrows from haskell quite heavily (The Don Syme and Simon Payton Jones have offices on the same hall at MS Cambridge)

Haskell has been proven in some very high end production environments. Many banks use it for things like trading systems. Due to how its type system works you have a lot of very strong guarantees about how your system will run. The only downside is that it is very different and learning it can be a bit of an effort.

You might also want to take a look at Erlang

Title: choosing a functional language platform for a new project

Body:
I have been writing code for a few years now and I don't believe I can claim to have a complete knowledge in this job yet.

My experience primarily rolls around C# related areas with a decent knowledge on Silverlight and Asp .Net MVC as well. I tend to use Sql server and Postgres for normal RDBMS related tasks with Mybatis or LinqtoSql as ORM (and Cassandra as well for NoSql).

Given that background, I am looking to building a new project which is a normal application using database and user interface screens. It is considerably a big project which we plan to be rolled out as a product.

In recent times, I see a lot of noises being made about functional programming like Haskell and F#. I am wondering
   - if it is worth to build the new system using Haskell
   - or just stick to a regular application building model using Silverlight/Prism with a layering similar to onion architecture

I understand the benefit of staying with the same technology background as it is always good to work on a familiar technology.

I also heard that by moving towards a functional language like Haskell we get cleaner code, improved testability etc.,

Is it really worth considering a move to build new systems in Hasekll? Or it is yet to be proven in production environments?

Simply put would I be safe if I build the new project using Haskell and my preferred database or it is too risky at this point in time to choose Haskell.

Any help appreciated.

Edit: I have already viewed a few other threads like the following and a few more as well, but did not get a definitive answer.
Choosing a functional programming language


问:
What are the monetary benefits of going agile?
Why go agile? This is the first question that comes to my mind when I think of going agile. What are the possible financial benefits one can achieve from going agile?

Most of us certainly like to think of customers and clients as someone who doesn't know what they wants. So why help them at all? Why not suck their money being a parasitic company and make them stupider by the day. Traditional software development isn't bad and are probably (mostly as far as I have seen) a lot easier environment to work in rather than agile projects.

So why go agile at all? What can agile give extra (I mean financially) that traditional software development can't?

答:
I suspect that by "traditional" you mean some kind of waterfall workflow.

The monetary benefits are many. The man-hours required for an extra feature to be implemented is the main thing. You can't stop the process once you start it, hence, if the client is not happy with what they get (and being 'stupid' the client only cares to get his job done, so if your software doesn't do that job properly you will lose the client).

Another one is the guarantee of satisfaction of the client, which also leads to more sales and more happy clients (and we want that from a business perspective).

Having the ability to feedback the development cycle also means that you can adapt to technological improvements (for example asp.NET mvc 4 that is coming right now) which also save a lot of time. Having set a strict spec for the project you can't upgrade to a newer/better technology/library/asset that would also potentially save time.

Time is money.


答:
Well, Agile is aimed at getting a finished product by an exact date.

Traditional waterfall if supposed to do the same, but often suffers due to scope creep not being managed properly.

Agile is supposed to better manage this into guiding the "business" into helping drive important features to be given higher priority and delivered first. The priority of items can change through the project as new information becomes available.

The benefit is that you deliver something more useful instead of being stuck continually missing deadlines.

Title: What are the monetary benefits of going agile?

Body:
Why go agile? This is the first question that comes to my mind when I think of going agile. What are the possible financial benefits one can achieve from going agile?

Most of us certainly like to think of customers and clients as someone who doesn't know what they wants. So why help them at all? Why not suck their money being a parasitic company and make them stupider by the day. Traditional software development isn't bad and are probably (mostly as far as I have seen) a lot easier environment to work in rather than agile projects.

So why go agile at all? What can agile give extra (I mean financially) that traditional software development can't?


答:
Agile produces better results (closer to what the customer needs, not necessarily what he initially says he wants), in less time = money (or at least with more reliable estimates). It's simply a better way of conducting projects (compared to "waterfall"). Customers are happier. Programmers are happier. Projects are better. Communication is true and transparent. Life is good. What's not to like, in professional sense?

If you have good salesmen, you may be able to sell crap to your customers and charge them more. Financially, this makes sense. The reality is way more complicated than the gullible view "if you make customers happy, your sales will increase; if you disappoint them, your sales will decrease". The world is not a fair place. You can make a good living as an asshole parasite. Many do. It's your choice whether you want to be one. If you are, I won't play with you.

It's no trick to make a lot of money, if all you want to do is make a lot of money. ~ "Everett Sloane" in Citizen Kane

Also:


问:
How to retain student/intern programmers?
We have a small team in our department and typically employ 1-3 students/interns.  The problem we have is retention.  We like to hire a student that will stick around as part of the team for more than just a summer quarter.  The problem is though the last 4 students we hired, up front we discussed this with them and they all ended up leaving earlier than we would have liked.

The relationships all ended in a good fashion, the students either obtained teaching assistant or research positions within the university, or went on to bigger and better things.  This is all understandable and we do not hold it against them for doing what is best for them.

But my perspective is different as I worked within our department for 2 years during undergraduate at which point I was brought on full time upon graduation.

How can we retain students?  We give them hardware they need/want, we provide them with problems to solve in anyway they see fit (within reason).  All in all to me this type of job for a student programmer is so flexible and awesome I cannot see how anyone would want to leave.

Thoughts ?

答: Technical questions in an interview are necessary, but try not to ask about things that the person could answer if they looked up in the documentation in under a minute. Even things that you think would be necessary (How do you take all commas out of a string) to be half decent. That kind of stuff they can figure out as they go if they are smart problem solvers. Look to see how they answer subjective technical questions rather than objective. Quite literally, you could ask some questions off of this site. Try to avoid Stackoverflow questions. It does not matter. If they can understand the higher level in a nuanced way and sound smart but humble while doing it, They will be able to tackle that language/technology stuff better in a couple months than their peers who have a lot more experience with it.</p>


问:
Are time restrictions on technical tests a good thing?
So we're having an internal debate on whether the time restriction that we have in place for our technical test a good thing. I thought I would open it out to the community. So what are your thoughts on this restriction, do people accept it as standard practice or is it an artificial restriction?

A little background, for all our positions, we expect candidates to complete a coding exercise and we set a time limit which we think is reasonable to at least layout the design (we don't expect a fully working solution), and it is this time limit which is under debate. The current time limit is 2 hours (which I frankly think is generous.)

答:
When it comes to interviews it makes sense to have time limits - otherwise you can end up interviewing all the time...

For coding exercises, the time limit should reflect expectations from the candidate - if you believe the exercise can't be finished in the allotted time you should communicate this to the candidate (otherwise they might believe they are expected to finish the whole thing and get discouraged and not do their best). You should also communicate what the candidate is expected to accomplish.

Even though this is an artificial limit, it needs to be in place - candidates know how long they have to spend on the exercise and it also tests how they self manage their time and how they self organize.


答:
One way you might evaluate the legitimacy of the time limit and the questions involved is to give the same exercise to a sampling of staff that are already employees. Otherwise you're literally guessing based on a preconceived idea about what someone "should" be able to do.

By doing small technical exercises in a short time you are evaluating a narrow indicator of performance on a very artificial situation. The results of such a test have to be taken in context with other factors. Probably not a good idea to use the results as a strict "go / no go" filter.

Title: Are time restrictions on technical tests a good thing?

Body:
So we're having an internal debate on whether the time restriction that we have in place for our technical test a good thing. I thought I would open it out to the community. So what are your thoughts on this restriction, do people accept it as standard practice or is it an artificial restriction?

A little background, for all our positions, we expect candidates to complete a coding exercise and we set a time limit which we think is reasonable to at least layout the design (we don't expect a fully working solution), and it is this time limit which is under debate. The current time limit is 2 hours (which I frankly think is generous.)


答:
I think, in general they are a good idea. It allows you to draw on another comparison between two candidates.

For example, if Candidate A completes the task in an hour and scores 80%, Candidate B completes the task in one hour and half and scores 80%. Naturally you would go for Candidate A.

Every other variants on this depends on your preference. Do you want someone that takes longer to do things but also does them very well. Or someone that does it quickly and does good enough.

It will also show you how the candidate reacts to a pressurised time limit (2 hours is far too long). If they rush, their code will be sh*te but others will take their time, even knowing they won't finish within their time limit.

It's entirely up to you essentially.


答: You seem to have the process in place for some times. I'd suggest to analyze its results. How do the candidates behave? How did the candidates you ended up by hiring behaved at the test? Were they satisfying?  Then you know if the current process is too lenient or not, and what are the problems it doesn't detect. (Sadly it is difficult to know if and why it rejected persons who would have been good hires).</p>


问:
Why is C++ still "hybrid"
On a related question, it has been clarified why C++ is not compatible with C in many aspects. However C++ is still a "hybrid"* language. And unfortunately, many programmers still consider C++ as a "C with streams and built-in strings". That results in really bad written code, that it's neither C++ nor C. IMHO, it would be better if the language/compiler forced to some extent programmers to write more elegant code. So is there a rationale for keeping modern C++ (for instance C++0x and future versions) hybrid?

* By hybrid I mean that it's up to the programmer to decide if he/she will use: standard strings and streams, classes, namespaces other than the default, etc.

答:
I think the fact that all those things you list are optional creates a potential for more elegance, not less. A feature used unnecessarily is inelegant in my eyes.

The problems that we need to solve using programming are very dissimilar.

Some are solved well using OO principles (e.g. GUIs), some lend themselves better to a purely functional treatment (e.g. numerical stuff), while some are best expressed in a low-level "close to the silicon" language.

Plenty of software needs to solve subproblems that are solved best in any one of those ways. Forcing the solution into a specific form will only lead to code that is less fit to its purpose (you might even say "less elegant").

This is why the hybrid-ness of C++ is a good thing - it lets us solve a vast array of problems in a way that suits the problem, not the current dogma.

Of course it can be misused - whenever you have a flexible thing there's a risk of you bending it in a bad way - but elegance comes from careful thought and experience, not from adherence to whatever is the fad du jour.

Title: Why is C++ still "hybrid"


答:
Time limits give you an out.  A competent dev should be able to come up with at least a first approximation solution, even if its just pseudocode or interfaces.  Someone who is not competent will immediately start coding, and will tangle themselves up.

I haven't done that many interviews (< 50 ) in my career so far, but I have found that candidates who finish within the time period are generally competent, whereas those who go over the time-limit are either detail-or-analysis-obsessed or incompetent, and further questions about their design can weed this out.


问:
Effective template system
I'm building a content management system, and need advice on which theming structure should I adopt. A few options (This is not a complete list):

Wordpress style:

the controller decides what template to load based on the user request, like: home page / article archive / single article page etc.

each of these templates are unrelated to other templates, and must exist within the theme

the theme developer decides if (s)he want to use inner-templates (like "sidebar", "sidebar item"), and includes them manually where (s)he thinks are needed.

Drupal style:

the controller gives control to the theme developer only to inner-templates; if they don't exist it falls back internally to some default templates (I find this very restrictive)

Funky style:

the controller only loads a "index.php" template and provides the theme developer conditional tags, which he can use to include inner-templates if (s)he wants.

Among these styles, or others what style of template system allows for fast development and a more concise design and implementation.

答:
How about selecting a PHP Development framework like Symfony 2 (http://symfony.com) or Zend Framework (http://zendframework.com) which have pre-build templating systems and you reuse those.

BTW Drupal is currently moving part of its core framework components to Symfony 2 so you may want to take a look at it.

Title: Effective template system


问:
What are the warning signs of impending doom to watch out for on a project?
Having worked on a failed project is one of the few things that most programmers have in common, regardless of language used, industry or experience.

These projects can be great learning experiences, soul-crushing disasters (or both!), and can occur for a multitude of reasons:

upper management change of heart

under-skilled / under-resourced team

emergence of superior competitor during dev cycle

over/under management

Once you've worked on a couple of such projects, is it possible to recognise at an early stage exactly when a project is doomed to fail?

For me, a big sign is having a hard & fast external deadline combined with feature creep. I've seen projects which were well planned out and proceeding right on schedule go horribly off the rails once the late feature requests started to roll in and get added to the final "deliverable". The proposers of these requests earned the nickname of Columbo, due to rarely leaving the room without asking for "just one more thing".

What are the warning signs you look out for that set off the alarm bells of impending doom in your head?

答:
For me, it is when those that are responsible for the feature set (aka managers, product owners, customers...) stop caring or seem to have a hopeless air about their answers.  Questions about features are meet with apathy and discouragement.  It is clear that they have lost investment or confidence in the project.

This happened for me when a project I was on had the "upper management change of heart" hit it.  I was asking questions about how it should work and all of a sudden no one had a real opinion.

A little while latter the project was canceled and all the beautiful code I had written was scrapped.


答:
There is no project that I know of that has been running indefinitely, such a thing is an utopia.

Since the prospective hire is going to be under permanent stress and his tasks will always be o a time limit, it comes naturally that he should be subjected to a test with a time limit.

But, be careful, him being able to finish the test under your time limit does not automatically make him competent (or the other way around) if you do not set the limit properly.


答:
Agile tackles the problem of how to "deliver" quality software with:

a) Changing requirements - even when the problem space is very clear, non-functional requirements like performance, security, compliance, etc can change core functionality.

b) Short delivery time frames - time to market is extremely critical so decisions have to be made on what is finished, and customers can expect to receive.

c) Fast changing technologies - changes in technology are so fast that it is difficult for projects to keep up.

d) Enhancements and Changing Market conditions - solutions have to evolve quickly evolve to meet changing market conditions, and add features to compete with other products.


答:
The air conditioning failing to work.

So the temperature in the office gets up to 40 degs in the summer of -5 in the winter.

The -5 not good for typing, as i can't wear gloves and type.
The 40, just slows my thinking down.

Title: What can slow a developer down?


答:
For me the benefit comes when doing fixed bid contracts. I've been able to win fix bid contracts and make an effective hourly rate that I would be ashamed to even speak by using agile methods. But it also requires a talented team that has gelled together to make it worthwhile.

You're right, it is easier to do a piss poor job, billing all along. Having worked in the industry for 16 years, I've seen my fair share of scandal. Especially during the dot-com boom. It's even possible to run the same scam, repeatedly getting away with it. But the same thing is possible in any industry. I've been scammed by car repair shops. Even the supposedly "reputable" ones. You hear stories practically every day about accountants embezzling from their clients, preachers stealing from their church, politicians taking bribes from big companies. And those are all classified as "white collar" crimes as if it makes it better. Oh they stole millions of dollars from their shareholders but it was a white collar crime.

There's nothing to stop you from taking advantage of people's trust and expectations. Personally, it's a matter of pride. I'd prefer to go to bed knowing that I exceeded the expectations of those I work with/for.


问:
How many user stories per person should be completed per sprint?
Just ran across this figure, and wondering if there's another well know source than would help confirm these numbers:

Based on data I analyzed on successfully finished sprints, I
determined that a team should average around 1 to 1-1/2 user stories
(product backlog items of any sort, really) per person per sprint.

SOURCE: Mike Cohn's Blog on "Should the Daily Standup Be Person-by-Person or Story-by-Story?"

答:
This would be a poor thing to worry about or even try to measure, this number is going to vary widely by skill of programmer, complexity of story, experience of programmer and team, experience of those creating stories, maintainability of code-base...

You should be worried about things like does everyone seem to be contributing to the best of their ability, is the client happier today than yesterday, does everyone/most think that this process is working better than the last process we tried?

ContentLicense: CC BY-SA 4.0


答:
Productivity is influenced by many factors - organizational culture, experience with the language and tools, knowledge of the project, specifics of the process being used, outside factors such as regulations, and the team's capabilities as a cohesive unit. This is why, when estimating projects, the most useful data is that of the specific team that will be conducting the work. As you generalize to organizational, industry, and then throughout software projects, productivity becomes a fuzzy area.

One of the advantages of iterative development is that you go through all phases many times on a single project, allowing you to gain insight into the process and the team. You might start with organizational data from past projects, but very quickly (2-4 iterations) get team-specific data for project planning.

The number that you cite (1-1.5 user stories per sprint) is the highest level of abstraction. The best time to use this number is when you have no industry-specific data from whatever domain your product falls in, no organizational data, and no team-specific data - early on in your first projects using Scrum. It probably comes from teams using all kinds of Scrum variants, including combining Scrum with other process improvement techniques (Kanban, CMMI, Lean). I'd trust using this number as it stands since Mike Cohn and Mountain Goat Software are well-respected agile consultants. However, as soon as you have data from your organization (or, even better, your team), use that instead for planning sprints.

Title: How many user stories per person should be completed per sprint?

Body:
Just ran across this figure, and wondering if there's another well know source than would help confirm these numbers:

Based on data I analyzed on successfully finished sprints, I
determined that a team should average around 1 to 1-1/2 user stories
(product backlog items of any sort, really) per person per sprint.

SOURCE: Mike Cohn's Blog on "Should the Daily Standup Be Person-by-Person or Story-by-Story?"


问:
Are code reviews necessary for junior developers?
I've worked at two companies, who each had a different methodology when it came to code reviews:

In the first company, a code review was conducted by the team leaders and was required after the completion of every module.

However, in the second company, team leaders weren't required to conduct any code reviews, and just checked for functionality and design issues.

So I am confused. Is the code review process really needed? If it is, why? And if it isn't, why not?

答:
I've been in the business for more than 20 years, working for software companies and for different businesses and none of these places had a code review process. However, I can understand and appreciate the benefits of having one. Essentially, as I understand them, they should be used to ensure adherence to standards, which should be followed in order for others to be able to more easily maintain the code in the future. Code readability might also be checked in a review process as this too will ensure that maintenance can effectively work with the code.

Currently, I work in a small shop where I am the single developer. Occasionally we have brought in contractors to help with the backlog. At least one or two of those contractors have written code that didn't necessarily meet mine or the companies' standards, but it did work well and was at least somewhat understandable. When I pointed this issue out to management, they didn't care, they just wanted to know if it did what we paid them to do.
So, I guess it just depends on the company, and whether or not clean, easy to maintain code is the desired product, or if they just want something that works well for the money.

Obviously as a developer, and one who has to maintain code, I would like to work with clean code that follows a standard of some sort, but I dont always have that luxury, so I make the best of it and deal with what I have, even if it means sometimes having to re-write some code in my own standard.


答:
For me, it depends on your sprint or depending the level of task to be done. From my current experience I am working on a system we created several user stories. for every week we would do stories that is assigned to be done on that week, if all task are done. we move to the next sprint even though we are ahead of schedule.(Assuming the task has been done correctly)

in my team for every person has 3 stories that is needed to be done. and I am surprised we are supassing our limitations.

it just depends on the programmer. but things like this should not be an issue. the issue here is that the client will get what they want or asked for.


问:
How to determine the priority and severity of a "code improvement"?
We have "priority" and "severity" fields in our bug tracking system. We define severity as "how it impacts the user" and priority as "how it impacts the product".

My question is about how to categorize a "code improvement" task in severity and priority. Suppose the improvement does not change any behavior but makes it a "better code". We anticipate a long term maintenance improvement overall but it's hard to quantify.

When we use our definitions for priority and severity, a code improvement gets the lowest values for both unless you introduce some hard to predict long term benefits into the picture. Therefore it implies that code improvement is a frivilous task and should never be attempted.

However I believe it's cruical to constantly improve and refactor the code, because:

Software development is itself a continuous learning process and without improving the code you can't get better at it.

A team should be proud of their code.

Future maintenance will take less time and over the long run savings will be significant.

Or do you think such tasks should never be created and such improvements performed only "on demand", "when associated with a bug"? Even if it's associated with a bug, wouldn't that be a discussion point on a code review, e.g. "why did you do this drastic change in structure?".

答:
If you want to refactor your code, set the priority of the task according to your definition (i.e. "how it impacts the product"). Some refactoring will not impact the product much and some will, depending on the scope of the work required. Setting a higher priority will indicate that more testing will need to be done after the refactoring is completed to ensure nothing unexpected has occurred.

You may also want to introduce a new category in your bug tracking system to categorize these kinds of tasks as "Refactoring" tasks. This way you will know how to interpret the priority value; that is, higher priority means larger impact and therefore more testing required.


答:
Interesting question.

I think you'd have to estimate how many lines of code and how many modules that a change might affect.

Maybe you could look at how many unit tests, if you have them, will get broken by making the change. This would probably mean trying the change in a branch first to get an idea.

Then have thresholds for these matching levels priority and severity.

You should also take into account have much tester testing will need to be involved. If the change touches a large surface area of the app, then a lot of system testing may need to be revisited.

Title: How to determine the priority and severity of a "code improvement"?

Body:
We have "priority" and "severity" fields in our bug tracking system. We define severity as "how it impacts the user" and priority as "how it impacts the product".

My question is about how to categorize a "code improvement" task in severity and priority. Suppose the improvement does not change any behavior but makes it a "better code". We anticipate a long term maintenance improvement overall but it's hard to quantify.

When we use our definitions for priority and severity, a code improvement gets the lowest values for both unless you introduce some hard to predict long term benefits into the picture. Therefore it implies that code improvement is a frivilous task and should never be attempted.

However I believe it's cruical to constantly improve and refactor the code, because:

Software development is itself a continuous learning process and without improving the code you can't get better at it.

A team should be proud of their code.

Future maintenance will take less time and over the long run savings will be significant.

Or do you think such tasks should never be created and such improvements performed only "on demand", "when associated with a bug"? Even if it's associated with a bug, wouldn't that be a discussion point on a code review, e.g. "why did you do this drastic change in structure?".


答:
Typically I do not like to view "code improvement" activities as a seperate assignable task because code improvement itself never directly brings you closer to completing user stories or requirements.  This is why code improvement tasks will always be such low priority that they never get assigned.

I see code improvement as a constant, something that every developer should be doing as naturally as typing on a keyboard.  I factor it into my estimates for any task.  If my task involves me touching a class or some source code that hasn't been looked at in a long while, then I will assume that some janitorial work is probably in order and increase my estimate accordingly.

Best case scenario I finish the task early and can use the remaining time to improve upon code or even design.  Worst case scenario the task takes much longer than expected but I have that extra time as a buffer.