答:
First, I would streamline the update process; try to integrate updating into the startup of the application itself (ClickOnce, perhaps a web service that's invoked on startup to check for updates and can automatically pull and apply said update). That makes upgrades less of a pain and thus you are able to release them more often if necessary.

Then, simply release an update to the update. It may help to somehow mark the update as "critical" and prevent users declining it (if they ever have the option). With the more streamlined update process, you'll cause fewer headaches, and you'll have less chance of people asking too many questions; you'll be seen as "responsive to user needs".


问:
Should I learn java for mobile application development or will C# just do?
I'm looking forward to delving into the .NET framework but most mobile applications seem to be developed in Java. I'll most probably be targeting the less pricier phones like Nokia and motorolla not android or iphone OS. Can I do these stuffs in C#?</p>

答: If you want to develop for Windows Phone 7, C# is perfect (VB.NET is coming soon.) You can leverage any Silverlight or XNA knowledge you have, too. I have no idea whether the platform will succeed, but why not refine your app using a language you know, then port it to other languages once you're confident in your user experience, logic, calculations etc? The emulator is apparently very good, and can be supplemented with accelerometer-emulator and gps-emulator to do everything except making a phone call. (And really, who uses smartphones for making calls?)</p>

OwnerDisplayName: Alexander Suraphel

ContentLicense: CC BY-SA 2.5


问:
How do you limit whitespace differences for developers using different IDEs/environments?
I've used UltraEdit for years and never had a problem with sharing code with fellow developers whether they worked on Windows, Mac, Linux, Eclipse, Visual Studio -- what have you...

But now I am in an office where some developers are using emacs and they complain profusely about the white space differences my code "introduces". I have UltraEdit set to write to files as UNIX-style (no Windows returns), but it seems the whitespace renders differently for the emacs developers.

Since I don't use emacs (or vi), its a pain for me to try to figure out why this is impacting them, but I more so just want them to shuttup! lol

This is even causing problems in SVN/Diff!

Any thoughts on how to fix this?

Forget about everyone using Emacs because thats not gonna happen lol.

答:
The tools available to you depend on the IDE you're using. VS and/or ReSharper in the .NET world can automatically enforce and convert whitespace differences or other "non-compliant" formatting, such as intercepting "tabs" and replacing them with 4 spaces, and converting existing tabs in the code. I'm sure UltraEdit has similar functionality if it is, as they claim, "the world's best hex/text editor". If it doesn't, there should be some plug-in that can normalize whitespace formatting.

And I really think Bernard's suggestion is the best solution; majority rule, choose a single development environment and standardize the set of tools.

ContentLicense: CC BY-SA 3.0


答:
The best solution is to use code formatter on check in. Strip trailing blanks, replace spaces with tabs.

Ide's always wreak havoc. But not using one, IMHO, is couter-productive nowadays.

Title: How do you limit whitespace differences for developers using different IDEs/environments?

Body:
I've used UltraEdit for years and never had a problem with sharing code with fellow developers whether they worked on Windows, Mac, Linux, Eclipse, Visual Studio -- what have you...

But now I am in an office where some developers are using emacs and they complain profusely about the white space differences my code "introduces". I have UltraEdit set to write to files as UNIX-style (no Windows returns), but it seems the whitespace renders differently for the emacs developers.

Since I don't use emacs (or vi), its a pain for me to try to figure out why this is impacting them, but I more so just want them to shuttup! lol

This is even causing problems in SVN/Diff!

Any thoughts on how to fix this?

Forget about everyone using Emacs because thats not gonna happen lol.


问:
Worth it to Learn an Archaic Language?

Possible Duplicate:

  Is COBOL still worth learning?

One of my better college professors often talked about the advantages of learning an archaic language (COBOL or SAP ABAP for example) in one's free time because of the advantages it provides when looking for high-paying jobs, or if you find yourself out of the job and in need of temp work(consulting, etc.). I was curious what your thoughts are on this, especially if you work with these languages, and whether the time investment could really pay off for future job hunts.

For a little background, I am a junior software developer relatively fresh out of college, with knowledge of mostly just Java, SQL, and web programming (JS, HTML, CSS, etc.) which have provided me with no lack of job opportunities thus far.

UPDATE: I thought this was interesting. I am currently looking for jobs (always a good thing to do in my opinion, and DICE makes it simple), and was just approached by a company for an SAP ABAP position where training in the language would be part of the job. Thank you everyone who responded, I will certainly take your advice into consideration!

答:
If it is classified in your mind or the mind of the community in general as archaic then I'd say stay away from it unless you have good reason to look into it. As was mentioned previously, it would be hard to compete with the rusty old developers who have been using those archaic languages for decades.

I will however agree with the larger premise of learning other languages, even some of the obscure ones. Much like the pragmatic programmer I would recommend learning one new language every year. I'd also take it a step further and say you should alternate different types of languages. One year learn a new dynamic language like Ruby or Python, then learn a new desktop language like Eiffel or Delphi, then learn a functional language like Haskell or Scala, then go for a web specific language or framework like jQuery, YUI, node.js, php or similar. If you get bored take a crack at a low level language like C, HLA, PowerBasic or straight up Assembler. By the time you make the full circle there will be new languages or frameworks to try.

The idea is that you will learn new approaches to solving problems that perhaps you had never been exposed to before.

Title: Worth it to Learn an Archaic Language?


问:
Why does shared state degrade performance?
I've been working under the share-nothing principle of concurrent programming. Essentially, all my worker threads have immutable read-only copies of the same state which is never shared between them (even by reference). Generally speaking, this has worked really well.

Now, someone has introduced a no-lock singleton cache (e.g. a static dictionary) that all the threads are accessing concurrently. Since the dictionary is never altered after startup there are no locks. There haven't been any Thread-Safety issues, but now there is a performance degradation.

The question is... since there are no locks why does the introduction of this singleton create a performance hit? What exactly is going on under the covers that could explain this?

To confirm, accessing this new singleton is the only change and I can reliably recreate this simply by commenting out the call to the cache.

答: It could be that the immutable state shares a cache-line with something mutable. In this case, a change to the nearby mutable state might have the effect of forcing a resynch of this cache line across cores, which could slow down performance.


问:
Documentation utility for OpenEdge ABL
I have a large system in OpenEdge ABL that could use some documentation-love. Currently a team member is working on a utility that can find methods and functions and make some "Javadoc-esque" html pages out of it. It's pretty rough around the edges. Okay, it's like sawblades around the edges.

I'm trying to find something like Javadoc or Doxygen that is capable of parsing OpenEdge ABL to generate some kind of API documentation. I know the market for OpenEdge isn't the best, but there is a lot of stuff that's passed along by word of mouth. It's difficult to search for because it used to be called "Progress" which throws off your search queries with non-relevant information.

I'm also open to a system that lets you define the regex's to look for to define your own syntax. Then it parses and gives you an output based on that.

答:
I wrote an xref->TT converter years ago which'll take apart your source files and return all sorts of stuff, including API's and their parameter lists. You can find the source code file here: http://communities.progress.com/pcom/docs/DOC-16588

One caveat is that I stopped working on this ~2008, so the code will be a bit out of date. If your code base doesn't use OOABL too much, I think you should be good.

Title: Documentation utility for OpenEdge ABL


问:
Introducing "20% time" at a workplace
20% time it's the culture of an employer allowing it's employees to spend 20% of their time working on projects that they find interesting - it may be inventing a new app, or improving an existing process, etc. Some people may know this as skunk work, however that term may not mean anything (or something entirely different) to you.

There are many documented cases of great products being born out of 20%/skunk work at a company. It seems like a win/win situation; the company potentially gain a great new product or application, and the developer has the opportunity to flex his/her creative muscles and innovate.

I tried on numerous occasions to introduce some form of 20%/Skunk working at my previous employer with no success.

How can I better justify it to management? What's the "right" way to approach this kind of work arrangement?

答:
The main reason for 20% time is to keep capacity utilization at 80% rather than at 100%.

You can think of a software development organization as a system that turns feature requests into developed features.  You can model its behaviour using queueing theory.

THEORY

If requests arrive faster than the system can service them, they queue up.  When arrivals are slower, the queue size decreases.  Because the arrival and service processes are random, the queue size changes randomly with time.

The mathematically inclined can ask about this "randomness": there must be some probability distribution, so what will the queue size be on average?  Math (queueing theory) has an answer to that: if both arrival and service processes are Markov, then N = rho^2 / (1-rho).

(Where rho is the utilization coefficient equal to the ratio of service and arrival rates.  If the processes are non-Markov, the math is more complicated, but doesn't change the conclusions.)

If you plot this function, you can see that the average queue length remains low while utilization is up to 0.8, then rises sharply and goes to infinity.  You can understand this intuitively by thinking about your computer's CPU: when its utilization approaches 100%, the computer becomes unresponsive.

PRACTICE

The economics of software development is such that software companies incur big costs when their queues are in high-queue states.  This includes missed market opportunities,  obsolete products, late projects, and waste caused by building features in anticipation of demand.

The 20% time is thus the scientific answer to the problem of optimizing economic outcomes: avoid high-queue states by avoiding utilization ratios causing them.  It is essentially the slack that keeps the system responsive.

Several practical conclusions follow immediately:

if you're considering 20% time and doing cost accounting (developers' time costs X, but/and the company can/cannot afford it), you're doing it wrong.

if you're allocating 20% to a Friday every week, you're doing it wrong

if you're setting up a 20% time project proposal submission/review/approval system, you're doing it wrong

if you're filling out timesheets, you're doing it wrong

if you're using innovation as a motivator for 20% time, you're doing it wrong.  While new products have come out of 20% projects, they were not the point.  If your company cannot innovate during its core hours, that's a problem!

20% time is not about creativity.  Don't say you'll unleash your creativity with 20% time, ask why you're not creative enough already during your core hours.

ANSWERS TO QUESTIONS IN THE COMMENTS

Dan, you got that right and accurately described the mistake made by many.  You cannot choose your utilization percentage, because it's an output variable.  It is a ratio of characteristics of two processes, so it is what it is because the processes are the way they are.  An organization does have influence over both processes; matching capability and demand is one of the hard problems addressed by the lean software development body of knowledge.  Utilization is one of the indicators how well this problem solved in an organization.  Slack emerges as your lean initiative progresses and you remove waste from the value stream.  But if you mandate 20% time, you end up in the same utilization trap with less available capacity.

Kim, it is still partially a culture thing.  The closest cultural reference I can think of is the synergistic level of the so-called Marshall model of organizational change.  It emerges at the end of successful lean transformations or is present in organizations built lean from the start.  (Here's a link to Bob Marshall's white paper (PDF).)

REFERENCES

The above logic is well supported in the software engineering literature.  Mary and Tom Poppendieck hinted at it in their 2006 book Implementing Lean Software Development.  Donald Reinertsen in his 2009 book Principles of Product Development Flow (Chapter 3) gives thourough treatment of this subject, with formulas and graphs.

Title: Introducing "20% time" at a workplace


问:
"Gödel, Escher, Bach" still valid today?
I have just completed a course on computability and logic which was an interesting course. The lecturer recommend a few books on his slides, which include "Gödel, Escher, Bach". I can see the book is quite famous, and looks very interesting. But I have a few questions to ask regarding its content.

Is the content still valid today? I guess most theoretical stuff doesn't change over night, but are there any major points which no longer hold today that I should be aware of?

I assume we actually HAVE made some progress in the last 30 years or so. Can any of you recommend a book on the subject which includes this progress (logic, AI, computability)?

Another question: Do I have to know about Escher and Bach?

答:
Gödel, Escher, Bach is a very unusual book.  A lot of concepts are presented and need a LOT of digestion to appreciate.  All you need to know is presented in the book, and you might find the explanation of Gödels Theorem (which is done quite well) and the various Turing-concepts fascinating.

Also the way he narrates a story similar to a six-part fugue still intrigues me.  And all the self-references, and the ALMOST-self references...

A fantastic book!

(and for fellow readers, I found the real ending to the book :) )


问:
How far has process-i-fi-cation of SW engineering come in the past 10 years?
I read a UML book a long time ago (15 or so years ago) by the inventors which said something like "software engineering should be like building a house".  Meaning architects produce blue prints, and specialized workers utilize various views of them to produce their part of the end result.

When I read it, it seemed reasonable, but from my perspective - I don't think much progress has been made to that end.  It might be that the goal was wrong, or unrealistic - I'm not sure...

答:
"software engineering should be like building a house"

Only when the entire house has already been built before.  Skilled carpenters and crafts people execute the same skills in different physical locations when they build houses.  They don't build new kinds of buildings.  They don't invent new construction techniques or materials.

Why build the same software twice?  Why rebuild the same house again?  Why not simply clone the software and reuse it?

The metaphor is totally broken.

Building software must involve something new or unique.  If it doesn't involve something new or unique, then it's already been done and it can be copied.  Problem solved.

New and Unique software features are either new technology or new use cases (or  both).

If it's new technology, then the architect doesn't just create blueprints.  It's new technology.  First, it has to be invented.  Then applied to the problem domain.  That requires experience, and failed experiments, and lessons learned.

If it's a new use case, then the architect doesn't just create blueprints.  It's new use.  The users must be interviewed.  The potential use cases tried to see if they work or don't work.  Corrections and adjustments need to be made.

Also.  Software is entirely design.  Even what we used to call "construction" was really detailed design, and a detailed set of experiments in a narrowly-focused area.  A programming language is really a design tool -- it provides a handy abstraction so we can separate our design from the chip circuitry on which it will ultimately execute.

The metaphor was totally broken.  It has always been totally broken.  Software is nothing like building a house.


答:
This view has fallen out of favor for the most part.  The short reason why is that when you have a software blueprint you're done.  The "specialized workers" that map to the building a house metaphor would be the build script.  Software development is more like making a giant blueprint, but even that metaphor isn't great.

Martin Fowler (see the Separation of Design and Construction section) has written about this for a while now, for example.

Title: How far has process-i-fi-cation of SW engineering come in the past 10 years?

Body:
I read a UML book a long time ago (15 or so years ago) by the inventors which said something like "software engineering should be like building a house".  Meaning architects produce blue prints, and specialized workers utilize various views of them to produce their part of the end result.

When I read it, it seemed reasonable, but from my perspective - I don't think much progress has been made to that end.  It might be that the goal was wrong, or unrealistic - I'm not sure...


问:
Cross-process asynchronous messages in .NET
(Asking this here instead of SO because I don't even know what technology to tag it with :))

My team is about to embark on a project to convert a large part of our code base to use asynchronous file I/O, as our file storage medium is increasingly being locate across a high-latency connection. We have some basic experience with asynchronous development, but this is on a larger scale than our previous work. At this point, I'm not even sure where to begin looking for technologies, patterns, or documentation on how to solve this problem.

The basic setup we have to work within has client applications with a user interface that sends file requests off to some locally-running background process, which does the actual work of communicating with the file storage services to obtain data. (This "proxy" layer is needed because we have a number of client applications that need to share the file services, cached results, etc.)

The design I have in my head would be for a client to submit a request to the service, which would in turn submit a request to the file storage services to begin an asynchronous I/O job. As progress was made downloading the file, the service would receive notifications, and would then fire off some kind of callback mechanism to the UI client to report process and/or completion. This means I need some sort of cross-process mechanism for executing callbacks.

Previously we have use duplex WCF services to implement something similar to this, but I am unsure if it will work properly in our current case. In particular, we want to handle the case where a client submits a request, then exits while the retrieval was in process. The service needs to be able to detect that the client has terminated but keep downloading the file; what I know about WCF duplex channels would imply that the client channel closing would terminate the service's channel as well. In addition, I would prefer not to require the client app to sit in some kind of spin-lock loop waiting for the async call to finish, but again, my research has led me to believe that the duplex callbacks only operate within the context of a single WCF call, so we would need to keep the calling thread around for the duration.

What other mechanisms are there for registering and sending callback-style messages across process? The team would prefer a fully-managed solution, though I'm certainly open to unmanaged options if they are significantly better in some way.

答:
As for patterns the "Enterprise Integration Patterns" book could be worth while. </p>

<p>As for technologies I think a service bus, like NServiceBus or MassTransit, might help you. </p>

Body:
As for patterns the "Enterprise Integration Patterns" book could be worth while.

As for technologies I think a service bus, like NServiceBus or MassTransit, might help you.


问:
Will Java still be relevant in 5 years?
Will Java have the same importance it had in the past, or it will be less relevant than nowadays?</p>

答: Java will not completely lose it's relevance for many more years, but it is certainly on a decline. If recent developments will affect that or if Oracle can change that remains to be seen. But I do think that one day I might be like COBOL, no new projects, but never quite dying either.</p>

Title: Will Java still be relevant in 5 years?


答:
I'm working for a start-up that has implemented the 20% policy. This is my first employer to do this, and when he brought it up at the job interview, I was really surprised, as most other employers were trying not to "waste" a single hour.

I joined the start-up when it was formed, and for almost a year I was the only developer. I spent my 20% with basically a couple of things:

Reporting/fixing bugs in random open source projects – this can be as small as forking an interesting project on Github & fixing a few typos in the docs.

Writing open-source "stuff" – things like programming challenges, just for fun.

Going to conferences and sprints – every few moths I'd go to a sprint where I can work on projects (some of which might be used by the main app, others not) and gain some experience. There are a few libraries that are used by our app and by apps developed by other companies who send developers to conferences, so it can be seen as a direct benefit to our company.

Learning new technologies – this is how I learned Go, even though we don't use it in the company. This is especially encouraged by my employer. Lately I've been following some of the Stanford free on-line classes.

The times are not measured precisely, it's definitely not 32+8 hours, sometimes there are urgent things to do when there's just not enough time to cut off that 20%, other times I have more time to spare.

I'm working remotely, and we use 37signal's Campfire chat to communicate and to loosely track each other's presence, and these hours are tracked as "working" hours, I'm logged on to the chat and available to co-workers, though making it clear that I'm not working on our project right now.

Title: Introducing "20% time" at a workplace

Body:
20% time it's the culture of an employer allowing it's employees to spend 20% of their time working on projects that they find interesting - it may be inventing a new app, or improving an existing process, etc. Some people may know this as skunk work, however that term may not mean anything (or something entirely different) to you.

There are many documented cases of great products being born out of 20%/skunk work at a company. It seems like a win/win situation; the company potentially gain a great new product or application, and the developer has the opportunity to flex his/her creative muscles and innovate.

I tried on numerous occasions to introduce some form of 20%/Skunk working at my previous employer with no success.

How can I better justify it to management? What's the "right" way to approach this kind of work arrangement?


问:
What happens between sprints?
I'm working on a project loosely following the scrum model. We're doing two week sprints. Something I'm not clear on (and don't have a book to consult) is exactly what is supposed to happen between sprints: there should be some "wrap" process, where the product gets built and delivered, but:

how long does this typically take?

should the whole team be involved?

does it strictly have to finish before developers start working on the next sprint items?

is this when code review and testing take place?

There are three developers, adding up to about 1 FTE. So the sprints are indeed very short.

答:
From my experience, there is no time between sprints, other than the weekend. Towards the middle of the sprint, the teams that I've been a member of work with the product owner to do some story grooming or preliminary sizings based on requirements. It's the product owner's responsibility to keep the backlog full - those stories are what the team will be working on, with some input from the product owner regarding priorities. Once the current sprint is done, the next sprint will start, utilizing the work that we've put in to prepare stories and tasks for the next sprint.

There is some overhead (lots of meetings, Q&A, and requirements evaluations), but overall it works - we make steady progress with little down time. Sprints have usually lasted either two or three weeks. QA usually takes place once stories are completed. However, the QA team might have other tasks that they can do. Regarding story grooming, tasks may fall to senior members of the team, or the whole team. It can vary depending on the size of the team and the process that's been agreed upon. Code reviews usually take place while QA occurs, or at the end of the sprint if time is compressed. And if there's not enough time to finish stories, in practice these stories get pushed to the next sprint. Proper sizing and estimation is very important here.

Title: What happens between sprints?


答:
I read a UML book a long time ago (15 or so years ago) by the
  inventors which said something like "software engineering should be
  like building a house". Meaning architects produce blue prints, and
  specialized workers utilize various views of them to produce their
  part of the end result.

That is an idealized view of actual construction work. Architects produce blueprints, which are in error and miss aspects. The civil engineer stamps it after checking it for architectural integrity, and occasionally gets it wrong. Carpenters, plumbers, et al, fix the various mistakes of the architect and engineers and work with the customer to make a pleasing building.

Have you ever heard of a house whose blueprints specified a wall where it couldn't fit? I have. Sounds a lot like software work, no?

People trot out "real" engineering fields but miss what happens there when new things are designed.  Rockets had a slew of designs in the 50s and 60s. Tons of rockets exploded and performed other malfunctions. Some still do. Jet planes test pilots were dying at the rate of one per week in the 50s in the US. The Tacoma Narrows Bridge design had a critical bug in it.MIT had a unique architecture in their one of their buildings and after a few years, it was leaky and not working well... probably literally buggy. =)  Keep prodding on the edge of creating and you will find flaws.

Every program you set out to write is solving a problem unique to your space, time and conundrum. Research is what you are doing when you dont' know what you are doing.

Software creation as the process gurus wish it to be is impossible by the nature of the task.  Software creation has been automated, actually. We call those tools compilers.


问:
Programming language with native concurrency support for large graphs?
I'm currently looking for a new programming language to learn (currently working through some C++, know some C and Python), specifically one that has built-in concurrency support? I want to try to build a large graph library that can do processing across clusters or multiple cores.. I know C++'s Boost library has support for concurrency, but I also want to learn a new language and I'm guessing a language that was designed with concurrency in mind would also be more pleasant to do concurrent programming in. Overall I see this as a chance to learn a new language, learn about concurrent programming, and tackle a big project.

From looking around, Clojure and Scala seem to be the two popular candidates when looking for concurrent programming support.. though I'm not sure how these two compare in terms of

Speed (specifically for concurrent large graph processing)

Community (thinking about pushing this project onto somewhere like GitHub)

Ease of programming concurrently

Or are there other languages I should consider aside from Clojure or Scala?

I have never programmed in a functional language before, but I'm open to learning it.. I've seen one of my friends program in Haskell and Clojure and it looks daunting but I've heard good things about functional programming, esp. for data processing.

Thanks!

答:
There are several concurrent programming languages.

Personally, I'd recommend looking into Erlang.  I don't know too much about it, but when researching concurrent programming, it seemed to pop up quite a bit, so I suspect there's a decent community for it.

Also, it seems that there are a couple of Python modules (greenlet and gevent) that could help you out, if you wanted to go that direction.


答:
I think that the founders of UML were visionary but 15 years ago the technology and hardware were not ready.
Software modeling technology has changed.
Eclipse and dotnet are getting better and better. There are today two different visions about UML. For IBM UML is an abstract view of the system using an MDA/MDD approach while for Omondo it should be the real world based on a single model live mapped to MOF and the code used as a component of a software factory. Both approaches are providing great value to project if used as it should be.

Hardware are now very powerful. For example my personal laptops can make more today than 10 mainframes 15 years ago, therefore graphical modeling layers can today be perfect while it was impossible before.

If you have been disapointed by UML I would say let's try again today using the latest tools and technologies.


问:
Application design for web/iPad/iPhone/Android application
I have a web application which is a pretty standard SAAS database driven app. I have a few customers asking for iOS or Android versions of the app. Is it better to build an API on the web app which is then used to drive the native mobile apps UI? This would be simplest but mean the mobile apps are not 'stand alone'. Alternatively I could try and implement a full mobile solution that then synchronizes with the web app somehow. This would be much more work as all the business logic needs to be build into the mobile apps rather than behind the API.

What is standard practice for this kind of thing?

答:
You may want to ask yourself a few questions. Do I want the app to function without an internet connection? How clean do I want the app to run? Are there any features I'd like to incorporate that are native to the devices? Do I care whether or not the app 'feels' native to the device?

As an iOS developer I've had to sit down with clients and sometimes my boss and go over these very questions. Sometimes we discover that, while what we had initially planned could be done with a web app, there are features we could incorporate through writing specifically for the device that was never an option before.


问:
Code Smell: Inheritance Abuse
It's been generally accepted in the OO community that one should "favor composition over inheritance". On the other hand, inheritance does provide both polymorphism and a straightforward, terse way of delegating everything to a base class unless explicitly overridden and is therefore extremely convenient and useful.  Delegation can often (though not always) be verbose and brittle.

The most obvious and IMHO surest sign of inheritance abuse is violation of the Liskov Substitution Principle.  What are some other signs that inheritance is The Wrong Tool for the Job even if it seems convenient?

答: If you are subclassing A to class B but nobody cares if B inherits from A or not, so that's the sign that you might be doing it wrong.

Title: Code Smell: Inheritance Abuse


答:
At a guess - because I've been there a couple of times - I would check what settings you are using for tabs, tab width and indentation in UltraEdit.

Some editors tend to be clever and compress spaces into tabs either while editing or when saving a file. If you don't have the same settings for saving tabs/spaces and tab width as your fellow developers this can cause all sorts of funny behaviour, both when it comes to viewing the file in a different editor and in a diff tool. I've got some prime examples here in some code that was edited by someone who couldn't be bothered to turn off the space->tab conversion on save.


答:
You probably have your IDE configured wrong for your work environment. Given you have no standards to work to, and anarchy reigns supreme (Implied by the existence of this question) you should configure your IDE to leave everything alone, except the lines you edit. I expect a tool such as Multiedit has this capability.

It is your responsibly not to change white space needlessly. I have learned (the hard way) this requires discipline and attention to detail, as well as an ability to leave things alone that are ugly, but not broken. It's not ideal, but without a guiding standard, all you will get into is pointless, destructive religious debate over whats right and wrong.

In the large (multi million line) code base I work on, as a rule changing code that does not need changing is wrong, and that is everything in the file - tabs, line ends, end of line spaces. The amount of merge conflicts that occur when pointless (white space, layout, comments etc)  changes occur is an expensive waste of time and effort. You can, with decent tools, mitigate this to some degree, but never completely.

Ultimately, try to agree to a standard format, and also a migration part towards that standard for legacy code. Preferably use tools to support (if not enforce) the chosen standard. (We have not been able to agree to this, the money men would rather pay for the hidden costs of not doing it)


答:
If you are looking for "standard practice", I think the answer would be to build a single API that all/most front ends use.  No reason why your webpage and your Android application can't be making the same API calls.

In reality, it all depends.  What does the application do.  Does it need an internet connection to get the latest data?  If it was a standalone application, how much data would be required for it to function.  I think it is hard to give the "right" answer without more details about what it is supposed to do.

Title: Application design for web/iPad/iPhone/Android application

Body:
I have a web application which is a pretty standard SAAS database driven app. I have a few customers asking for iOS or Android versions of the app. Is it better to build an API on the web app which is then used to drive the native mobile apps UI? This would be simplest but mean the mobile apps are not 'stand alone'. Alternatively I could try and implement a full mobile solution that then synchronizes with the web app somehow. This would be much more work as all the business logic needs to be build into the mobile apps rather than behind the API.

What is standard practice for this kind of thing?


答:
Java will be relevant for the foreseeable future, even if you define relevant to only include new code, not legacy maintenance mode.  Yes, the language sucks and treats its programmers like naughty children instead of consenting adults and hasn't had a facelift since the Stone Age.  On the other hand:

Java has some awesome libraries.

The JVM is an awesome platform.

You don't have to program in Java to use these libraries, now that there's been a proliferation of JVM languages.

IMHO the way things will evolve is that Java in the JVM world will become what C is in the natively compiled world.  People will use Scala, Jython, Groovy, etc. in day to day coding, but will keep calling old, crufty Java code from these languages for eternity.  Certain performance-critical code might still be written in Java, because it's probably the lowest-level, most efficient JVM language.  Old libraries will need new features added.  Therefore, Java will remain highly relevant even if it's not used by the average programmer day to day.

Title: Will Java still be relevant in 5 years?

Body: Will Java have the same importance it had in the past, or it will be less relevant than nowadays?</p>


答: You fix this by creating a standard style guide for your organization's code. Everyone then configures their editors to match that style guide. For example you choose either tabs or spaces for your indentation and how wide indentations should be. This eliminates inconsistencies in and makes it so there is no arguing about code formatting, because the answer should be in the style guide. Ideally you would also have a tool that ensures code matches the style guidelines before it is checked in. For an example, see google's C++ Style Guide</p>


答:
On the Windows platform F# is a good choice if you like .NET

F# is the closest to a functional programming language of all the languages from Microsoft. Functional progamming languages (like Haskell and ML ) by their nature encourage a programming style (idiomatic expressions) that the compiler can easily translate into code that can use multiple cores/CPUs.

For an example of how the Async and Paralell design patterns encourage this see : http://blogs.msdn.com/b/dsyme/archive/2010/01/09/async-and-parallel-design-patterns-in-f-parallelizing-cpu-and-i-o-computations.aspx

Perhaps a specific example would be helpful. This code will compute the first 40 Fibonacci numbers concurrently:

```<code>let rec fib x = if x <= 2 then 1 else fib(x-1) + fib(x-2)

let fibs =

    Async.Parallel [ for i in 0..40 -> async { return fib(i) } ]

    |> Async.RunSynchronously
</code>```

This sample is taken from here.

Title: Programming language with native concurrency support for large graphs?

Body:
I'm currently looking for a new programming language to learn (currently working through some C++, know some C and Python), specifically one that has built-in concurrency support? I want to try to build a large graph library that can do processing across clusters or multiple cores.. I know C++'s Boost library has support for concurrency, but I also want to learn a new language and I'm guessing a language that was designed with concurrency in mind would also be more pleasant to do concurrent programming in. Overall I see this as a chance to learn a new language, learn about concurrent programming, and tackle a big project.

From looking around, Clojure and Scala seem to be the two popular candidates when looking for concurrent programming support.. though I'm not sure how these two compare in terms of

Speed (specifically for concurrent large graph processing)

Community (thinking about pushing this project onto somewhere like GitHub)

Ease of programming concurrently

Or are there other languages I should consider aside from Clojure or Scala?

I have never programmed in a functional language before, but I'm open to learning it.. I've seen one of my friends program in Haskell and Clojure and it looks daunting but I've heard good things about functional programming, esp. for data processing.

Thanks!

Body:
On the Windows platform F# is a good choice if you like .NET

F# is the closest to a functional programming language of all the languages from Microsoft. Functional progamming languages (like Haskell and ML ) by their nature encourage a programming style (idiomatic expressions) that the compiler can easily translate into code that can use multiple cores/CPUs.

For an example of how the Async and Paralell design patterns encourage this see : http://blogs.msdn.com/b/dsyme/archive/2010/01/09/async-and-parallel-design-patterns-in-f-parallelizing-cpu-and-i-o-computations.aspx

Perhaps a specific example would be helpful. This code will compute the first 40 Fibonacci numbers concurrently:

let rec fib x = if x <= 2 then 1 else fib(x-1) + fib(x-2)

let fibs =

    Async.Parallel [ for i in 0..40 -> async { return fib(i) } ]

    |> Async.RunSynchronously

This sample is taken from here.

ContentLicense: CC BY-SA 4.0


问:
How to deal with people who don't want to share knowledge?

Possible Duplicate:

  How do you deal with an information hoarder?

Often, in IT teams knowledge equals power. This is fine as long as (IT-)knowledge is equally accessible by all members of the team and company specific know-how is well documented. Sometimes personnel in an IT department build up a tremendous amount of know-how without documenting it. By doing so they think that they ensure their position. Often these people like it when people specifically have to ask them how to do a job.

How do you get these programmers, database administrators or other IT staff to DOCUMENT their work and make it accessible to the company they work for?

EDIT:
It's a relief that so many of you know this type of person. That it is not me bumping into them everywhere I do projects. On the other hand it makes me sad, such talented people but in many ways behaving as a child. I have seen the behavior in men and women btw. It is hard to pick one answer as the best and accept. Will do after more re-reads.

答:
The first question to ask is 'Why are they not sharing knowledge?"

If it is for job security, then address that issue head on. If it is a senior person with a top salary they may have a very legitimate fear that the company would lay them off and replace them with a cheaper, more junior person or even outsource their job overseas. We all know of lots of such companies, so this can be a real fear. One effective way to deal with this is to say "If you will agree to share your knowledge we will give you a guaranteed employment contract for X years." Of course if your goal is to outsource the job as soon as you pick their brain then perhaps they have simply seen through your strategy....

Another possibility could be that they would be happy to share but they are introverted, don't like to speak in front of groups, don't like to write etc. In this case hire a person who is an excellent writer and assign that new person as this persons assistant. Their job would be to learn what the person knows, write it down and communicate it to the organization.

Please remember that generally a person becomes a programmer because they want to program. If their first love is teaching they would be an educator, not a programmer. If their first love was running training seminars, they would be running training classes at a consulting firm. When you want someone to do something outside of their comfort zone the first thought should be "how can I help them?" The second thought should be "How can I make it worth their while?"

Consider what would happen if your department scheduled a one week training retreat in Hawaii and you announced that anyone willing to give a half day training session could go for free.  Further everyone would vote on which sessions were the most useful and the person with the most votes would get a $10,000 bonus and the runner up would get $5,000. DOn't you think you would get lots of people working extremely hard to deliver sessions where they share their knowledge?


问:
Observer pattern; knowing *what* changed?
I've created two abstract classes Subject and Observer that define a classic Observer pattern interface.  I derive from them to implement the Observer pattern.  An observer might look like this:

```<code>void MyClass::Update(Subject *subject)
{
    if(subject == myService_)
    {
        DoSomething();
    }
    else if(subject == myOtherService_)
    {
        DoSomethingElse();
    }
}
</code>```

This is fine and it tells me who changed something.  However, it doesn't tell me what changed.  Sometimes this is ok because I'm just going to query the Subject for the latest data, but other times I need to know what exactly changed on the Subject.  I notice in Java they have both a notifyObservers() method and a notifyObservers(Object arg) method to presumably specify details about what changed.

In my case I need to know if one of a couple different actions happened on the subject and, if it's a particular action, to know an integer number related to that action.

So my questions are:

what's the C++ way to pass a generic argument (as Java does)?

Is Observer even the best pattern?  Perhaps some kind of event system?

UPDATE

I found this article which talks about templating the Observer pattern: Implementing a Subject/Observer pattern with templates.  This made me wonder if you could template an argument.

I found this stack overflow question which talks about templating the argument: Template based Subject Observer pattern - Should I use static_cast or dynamic_cast.  However, the OP seems to have a problem that no one has answered.

The other thing I could do is change the Update method to take an EventArg object as in:

```<code>void MyClass::Update(Subject *subject, EventArg arg)
{
  ...
</code>```

And then create subclasses of the EventArg for specific argument data, and then I guess cast it back to the specific subclass within the update method.

UPDATE 2

Also found an article, On creating an asynchronous message-based c++ framework; part 2 which discusses having the Subject communicate details about what changed.

I'm now seriously considering using Boost.Signals.  Using my own observer pattern made sense when it was simple, but templating the type and an argument is starting to get complicated.  And I may need the thread safety of Boost.Signals2.

UPDATE 3

I also found some interesting articles on the observer pattern:

Generalizing Observer by Herb Sutter

Implementing the Observer Pattern in C++ - Part 1

Experiences of Implementing the Observer Design Pattern (Part 2)

Experiences of Implementing the Observer Design Pattern (Part 3)

However, I've switched my implementation to using Boost.Signals which, while possibly tad bloated for my purposes, is successfully working.  And probably any concerns of bloat or speed are irrelevant.

答:
Whether C++ or JAVA, a Notification to the observer can come along with the information of what is changed. The same methods notifyObservers(Object arg) can also be used in C++ as well.

Generally, the issue will remain is that there could be multiple subjects dispatching to one or multiple observers and hence, the class arg cannot be hard coded.

Usually, the best way to do is to make arg in the form of generic message/tokens that forms the same data type for various classes but values differ for different observed classes. Alternatively, if all such notification values are derived out of the class on some based class which is common to all.

For observer pattern, it is important that Arg data type is not hard coded between the observee and observer - else it is a coupling that makes things difficult to evolve.

EDIT

If you want that observer not only observes but also needs to do a lot of other tasks based on the what has changed then, you can also check out Visitor pattern. In visitor pattern, the observer/visitor calls the modified object and hence can not only know what the modification is but can actually work on it


答:
When it comes to concurrency, avoiding shared state is key. A few paradigms and languages naturally lend themselves for concurrent programming because of this:

the message-passing paradigm, a core concept in Smalltalk and (AFAIK) Objective-C; the idea being that the building blocks of your program communicate through messages, which naturally manages shared state in a concurrency-friendly way

functional programming in general avoids state; especially when purity is enforcable (after all, a pure function cannot have any shared state at all). Languages to look into in this context are plentiful; popular ones include several LISP dialects (Common Lisp, Clojure, Scheme), the ML family (ML, F#, Haskell), and Erlang. Haskell is especially interesting because it defaults to lazy evaluation and enforces complete purity (that is, you cannot write non-pure functions in Haskell). Haskell, being designed as a compiled language, can also be very performant, as close to C as one can probably get with such a high-level language.


问:
Are Domain Objects in Domain Driven Design only supposed to be write-only?
I've been reading about Domain Driven Design for almost two years and have been cautiously been introducing some concepts in to my daily work or at least making plans for how things I do regularly could be done within a Domain Driven Design.

One conclusion that I've beginning to come to especially in response to reading more about Event Sourcing and Command Query Responsibility Segregation (CQRS) that perhaps domain objects are intended to be used only for write purposes. To be more clear, it seems that what people are subtly suggesting in much of the documentation I've read that the domain objects are responsible for doing domain centric operations/calculations, validation, and then are there mainly to provide a road to persistence through the infrastructure provided within a Repository implementation. Although I do like the fact that this may simplifies the domain model greatly as it cuts out the responsibility of exposing state.

If it is indeed correct that domain objects are mainly to be used as write-only objects then that raises some questions for me that I'm hoping somebody could answer.

How does one perform unit tests on an object that has setters, or methods that modify the state of an object but that provide no outwardly public interface to read the state from such as property getters in C#? Is it okay to expose state solely for the purpose of making that object testable?

How does one show to a user the results of calculations or operations done in the domain without having to persist them and then pull the results from persist store outside of the context of the domain? Is it okay to expose state solely for the purpose of showing results.

Is the rule of thumb that the only property getters (get accessors) should be ones that are also writable in the domain? Or said differently should readonly properties be the only thing to avoid since they are only there for read purposes and thus do not play a a necessary role in the actual domain model?

Related material:

TDD, DDD and Encapsulation

答:
Your domain model unit tests should be checking that for each command executed the correct domain events are raised. Your domain commands and captured events can be interrogated for state.

You could also override ToString() on your domain commands and events to provide automatic, human readable reporting of state.

To answer your second question, to display the results of commands you should arrange for domain events to be 'published' to your read-model.


问:
Does not testing internals entail diligent refactoring and/or rely on developer talent?
I'm not asking here what the arguments are for/against testing
internal methods (though I'll restate some, and don't mind hearing
others). My questions relate to the implications of only testing
public interface.  Especially, whether I understand the extent of the
"refactor" part of Red-Green-Refactor in by-the-book TDD, and if there
are non TDD techniques TDD practitioners use that address the problems
that make me want to test internals.

My question is: If you write the most straightforward code possible to
get the light green, and if you don't test internal methods, does it
follow that from time to time you allow yourself to start off by
writing a class that does far more than it should with a bunch of
member variables you know will not survive refactoring?  And wind up
after refactoring with a bunch of methods that aren't explicitly
tested?

As I get familiar with TDD, it feels like anyone would at least be tempted to
test internal methods.  And many practitioners flatly say you shouldn't.
E.g. (of about 23 million results):

Item 2 here and it's comments and this StackOverflow post

Given an implementation will involve more than one non-trivial
problem, if you only test the public interface, there are two
possibilities: 1) non-trivial logic winds up getting tested only
indirectly, AND tested in the same calls as other non trivial logic.  2) you make methods
public that you don't expect clients other than the SUT and the tests
to call.  I think what I hear from the advocates of by-the-book TDD is
"1 is right.  Yes, a lot of non trivial code is tested only
indirectly, and that isn't a problem.  After all, you don't want your
tests to start failing when you improve the implementation.  Even if
they don't fail, it's not innocuous if tests keep passing when they're
targetting a bunch of no-longer-used code, because the tests show how
to use your class. You Should Only Test the Public Interface."  And
that sounds like a reasonable thing to say, but I haven't seen it said
explicitly.

But even though it sounds reasonable -- if I don't test internals I
feel like I lose part of what helps keep the tests DRIVING the coding
(maybe part of my difficulty applying the precepts is that I don't
distinguish between coding and developing).  If there's some internal
logic that has to turn a String to a valid int32, int64 or decimal
value depending on what's in the string and the type of some other
object, I want to test that little bit of logic, not just find out
that the whole method failed.  I want one test to pinpoint those few
lines of code and exercise what should fail.

The thinking in the doubly downvoted answer here seems so obviously attractive that I have to wonder if the
by-the-book fellows are neglecting to mention some
instrumentation/tracing/logging code they use in addition to TDD, or
if they watch it work in a symbolic debugger.  Or do they just
recognize that as a failure point and write a test with input that
will cause a failure pinpointing those few lines of code?  If they do
that it's testing the implementation though.  It seems so natural to
want to test that code in isolation, and verify it fails where it
should, even though it's an implementation detail.

I suppose that with talent and experience you can classify bigger chunks
of code as "non-trivial" but I haven't seen anyone bluntly saying or condescendingly implying that
that's why they don't have to test implementation details.

Lots of time it makes perfect sense to me to test the public
interface, lots of methods really are like what you see in TDD
examples.  But for the feel of where I wonder if purists are doing
something more than writing tests on a public member: Say you want to
put data from an ISAM file into a database.  There is one public
method to the envisioned consumer of the code: public void
LoadIt(SqlConnection c).  "Loadit" has a bunch of other dependencies
that will be resolved using configuration files and environment
variables: some code has to determine that it can find the name of the
folder where the ISAMs live; to find, load and parse the schema file
for the isams using the ISAM vendor's DDL library; so forth+so on.
But none of that is of any interest to any envisioned calling code.

My only reason for moving the dependency resolvers out of the
Loadit class would be so I could test them OR to make the code easier
to understand/maintain.

Moving to another class to make them testable is Doing It Wrong --
they're really just implementation details of LoadIt.  And in my first
implementation, I am just trying to write enough code to get the light
to turn green.  So I won't write anything with reasonable
maintainability if it's easier to just manhandle a bunch of variables
in a big method or two.  I won't write helper classes.  Instead, I'll
get the light green and then do the Refactor part diligently.  Even
when I clean it up, any classes introduced keep "internal/friend"
accessibility, and only get tested via the call to LoadIt.

Thanks for reading this far; as a reminder, my question is in the
second paragraph.

答:
You have a lot of intertwined questions.. the post was long and I'm confused. But let's work at it..

First off second paragraph.

The common answer is not that you don't test internal/non-public methods, rather you do not test them directly via tests. The internal methods should be called by one or more types and their tests would end up verifying the internal methods as part of their execution. Reason: Refactoring becomes hard. e.g. It should be easy to move around private methods as long as you don't break the behavior. But if you have tests for these methods, then you end up breaking and fixing a lot of tests even though the functionality is intact. Remember refactoring is behavior-preserving and structure-improving.

Ending up with code that isn't tested. As long as you write the simplest thing that can work to make something green and refactor, you never end up with any code that isn't pulled in by at least one test. You can make the test pass with a hack like return "canned value". But then the next test should expose this and pull in the real code.

You shouldn't have to increase visibility just for testing (make things public just for testing) but you need to design for testability. This may sound like a paradox, but an example would be.. don't new up dependencies within your method. Rather accept dependencies via ctor/method arguments. This allows your tests to easily substitute a fake dependency.

Your example: I would have

one test for Migrator.Transfer(DataSource, DataDestination) where the params are tech-agnostic roles/interfaces.

one integration test-suite to verify a real ISAM implementation of DataSource; that verifies the class can get data out of a real ISAM store

one integration test-suite to verify a real [insert DB tech] implementation of DataDestination; that verifies the class can insert data correctly into your DB>

OwnerDisplayName: MakeMinePanacea


问:
Evaluating Software Maintenance
1. When to treat a software as deployed and when to start charging for maintenance ?

In most of the cases the software we make is deployed on the web at early stages to enhance the testing process from the client side. This means that bugs keep arising and we keep fixing them alongside development. Not just that, as the clients use it, they come to know of modifications required which creates a pile of extra work for us. Because of no demarcation line between development, deployment and maintenance stages its hard to understand when to charge for what.

2. How to charge for software maintenance ?

I read that vendors charge 15%-22% generally for softwares annually. That being a fixed fee what happens if the maintenance takes more time then expected ? What happens if the system runs fine or without issues for an year ? Does the client still pay maintenance ?

3. How to charge for non-application specific improvements ?

We use a core engine to build business applications. Improvement in that engine means improvements, new functions, etc can be made available to all clients without modifying their application layer. Should that be included in maintenance as free upgrades ?

4. How to charge for maintenance in case of hourly contracts ?

If we work on an hourly project most of the times the scope of the project keeps expanding but that doesn't require a revaluation of the project because the increase in scope equates to increase in hours and hence increase in budget. But most of the times due to increase in the scope the bug fixing and maintenance work also gets included in the development time. Is that good ? Or should there be a demarcation between deployement and maintenance even for hourly projects ?

答:
All these things are very subjective and are based on what your clients expectations are.

The maintenance charge seems to be in a sensible range, and matches my expectations for it - the idea isn't that you charge the client for every bit of maintenance you do, but that this charge is meant to cover your costs for providing ongoing maintenance. Obviously, the more bugs your software has, the more time you're going to spend on maintenance. As far as your clients are concerned, this is your problem.

You do need to draw the line between what counts as a new feature and what is maintenance, and the best way to do that is to have a definitive spec for each feature; if it's not in the spec, and you feel it's a significant change to current functionality, then it's a new feature. If it's existing functionality that doesn't work correctly, then it's maintenance.

That's how I draw the line, but recognise that most clients will try to push back on this wherever possible, as it will save them money!

Title: Evaluating Software Maintenance


问:
Dynamically generating HTML and CSS
I find writing CSS by hand to be extremely tedious.

Coming across a concept such as fluid, makes me want to write all my websites so that the CSS resizes nicely and looks the same in different browsers.

My question to you is: Can my design be generated programmically?

e.g.:

```<code>#include <css>
#include <html>
#include <vector>
#include <string>

int main(void) {
    HTML::HTML page;
    page.title("my title");
    page.heading.font(15);
    std::vector<std::string> para = <vector of paragraphs>;

    CSS::CSS layout;
    layout.grid(2,2);
    layout.fill(xcoords_as_percentage, ycoords_as_percentage);

    page.use_css(layout);
    for(int i=0; i<para.size() && y!=grid.y.size()+1; i++, x++) {
        if(x==grid.x.size()) x=0, y++;
        page.grid[x][y]=para[i];
    }
    page.header1("I am header1");
    page.footer("I am page footer");
    layout.order(page.header1[0], page.grid.all(), page.footer());

    generate_html("index.html");
    generate_css("layout.css");
}
</code>```

This will allow me to concentrate on the actual contents, abstracting away from "Oh, IE7 doesn't support this option, so do this hack..."

FYI: I am coding the actual site in Django (Python), so the HTML/CSS generator doesn't have to be in C++. I am aware of work being done in this direction in the C++ Wt framework

答:
This question is more proper on Stack Overflow, but.. it sounds like you want to use a programmatic CSS language/framework, like SASS or Stylus:

http://sass-lang.com/

http://learnboost.github.com/stylus/

In particular, variables, functions and mixins are very useful in these languages.

Title: Dynamically generating HTML and CSS


问:
Why is C++ predominant in programming contests and competitions?
I understand that C++ is a very fast language, but ain't C just as fast, or faster in some cases?

Then you might say that C++ has OOP, but the amount of OOP you need for most programming puzzles is not that big, and in my opinion C would be able handle that.

Here's why I am asking this: I am very interested in programming contests and competitions, and I am used to coding in C on those. However, I noticed that the vast majority of people use C++ (e.g., 17 out of 25 finalists on Google Code Jam 2011 used it, while no one used C), so I am wondering if I am at a disadvantage going with C.

Apart from the Object Orientation, what makes C++ a more suitable language for programming competitions? What are the features of the language I should learn and use to perform better on the competitions?

For background, I consider myself pretty proficient in C, but I am just starting to learn C++.

答:
To start with, there will always be some problems that are better solved in one language than another. There will always be languages that solve specific problems "better" than any other language, for some definition of "better". However, a very very large number of problems have very similar needs (some I/O, some computation) and face similar requirements (reasonable reliability, reasonable performance).

As you know C already, for the vast majority of problems out there, I state that C++ provides no significant downsides and a number of significant improvements.  Bold? Some people seem to think so, but it's really the case. Let's start out by clearing up a few very common C++ misunderstandings:

C++ is slower than C.  Wrong! Many C programs are valid C++ programs as well - and such a C program should run at identical speed when compiled with either the C compiler or the C++ compiler.

C++ specific features require overhead. Wrong! The so-called overhead introduced by certain C++ specific features (such as virtual function calls or exceptions), is comparable to the overhead you yourself would introduce should you implement a similar feature in C.

C++ is object oriented. Wrong! The C++ language contains some language extensions that facilitate object oriented programming and generic programming. C++ does not force object oriented design anywhere - it merely allows it.  C allows for object oriented programming as well, C++ only makes it simpler and less error-prone.

So, if you believe me, we have established that "C++ is not significantly worse than C". Let's have a look at what makes C++ a better C:

Stronger typing The type system in C++ is stronger than in C. This prevents many common programming errors - coupled with the next very important feature, the stronger type system even manages not to be an inconvenience.

Parameterized types The template keyword allows the programmer to write generic (type-agnostic) implementations of algorithms. Where in C, one could write a generic list implementation with an element like:

```<code>struct element_t {
  struct element_t *next, *prev;
  void *element;
 };
</code>```

C++ allows one to write something like:

```<code>template <typename T>
struct element_t {
   element_t<T> *next, *prev;
   T element;
};
</code>```

Not only does the C++ implementation prevent common programmer errors (like putting an element of the wrong type on the list), it also allows better optimization by the compiler! For example, a generic sort implementation is available in both C and C++ -

the C routine is defined as:

```<code>void qsort(void *base, size_t nmemb, size_t size,
           int(*compar)(const void *, const void *));
</code>```

whereas the C++ routine is defined as

```<code>template void sort(RandomAccessIterator first, RandomAccessIterator last);
</code>```

The difference being, that for example sorting an array of integers, would, in the C case, require a function call for every single compare, whereas the C++ implementation would allow the compiler to inline the integer comparison calls, as the actual sort routine is automatically instantiated at compile time by the compiler, with the correct types inserted in the template arguments.

A bigger standard library  C++ allows the full use of the C standard library. This is very important of course, as the C standard library is an invaluable resource when writing real world programs. However, C++ includes the Standard Template Library. The STL contains a number of useful templates, like the sort routine above. It includes useful common data structures such as lists, maps, sets, etc. Like the sort routine, the other STL routines and data structures are "tailored" to the specific needs the programmer has - all the programmer has to do is fill in the types.

Of course, the STL is no silver bullet - but it does provide a great help very often, when solving general problems. How often have you implemented a list in C? How often would an RB-tree have been a better solution, if only you had had the time to do it? With the STL you do not need to make such compromises - use the tree if it's a better fit, it's as easy as using the list.

Ok, so I've only been discussing the good parts. Are there any downsides? Of course there are. However, their number is shrinking day by day.  Let me explain:

There are no good C++ compilers It's been like this for a long time. But you must remember, that the language was standardized in 1998 - it is a complex language, more complex than C. It has taken a long time for compilers to catch up to the standard. But as of this writing, there are good compilers available for the most widely used platforms out there; GCC in versions 3.X are generally very good, and it runs on GNU/Linux and most UNIX platforms. Intel has a good compiler for Win32 - it is also pretty good, but unfortunately it still relies on the MS STL which is sub-par.

People don't know good C++ This is not an often heard complaint, but it's something that I see a lot. C++ is a big and complex language - but it also used to be a language that was hyped a lot, especially back in the "OOP solves hunger, cures AIDS and cancer" days. The result seems to be that a lot of really poor C++ code, basically bad C with a few class declarations here and there, is out there and is being used as learning material. This means a lot of people who believe they know C++ actually write really crappy code. That's too bad, and it's a problem, but I think it's unfair to blame this on C++.

So, the only two major problems with C++ are results of C++ being a young language. In time they will vanish. And for most problems out there, if you can get good programmers (or learn good C++ yourself), the problems are not really an issue today.

Body:
To start with, there will always be some problems that are better solved in one language than another. There will always be languages that solve specific problems "better" than any other language, for some definition of "better". However, a very very large number of problems have very similar needs (some I/O, some computation) and face similar requirements (reasonable reliability, reasonable performance).

As you know C already, for the vast majority of problems out there, I state that C++ provides no significant downsides and a number of significant improvements.  Bold? Some people seem to think so, but it's really the case. Let's start out by clearing up a few very common C++ misunderstandings:

C++ is slower than C.  Wrong! Many C programs are valid C++ programs as well - and such a C program should run at identical speed when compiled with either the C compiler or the C++ compiler.

C++ specific features require overhead. Wrong! The so-called overhead introduced by certain C++ specific features (such as virtual function calls or exceptions), is comparable to the overhead you yourself would introduce should you implement a similar feature in C.

C++ is object oriented. Wrong! The C++ language contains some language extensions that facilitate object oriented programming and generic programming. C++ does not force object oriented design anywhere - it merely allows it.  C allows for object oriented programming as well, C++ only makes it simpler and less error-prone.

So, if you believe me, we have established that "C++ is not significantly worse than C". Let's have a look at what makes C++ a better C:

Stronger typing The type system in C++ is stronger than in C. This prevents many common programming errors - coupled with the next very important feature, the stronger type system even manages not to be an inconvenience.

Parameterized types The template keyword allows the programmer to write generic (type-agnostic) implementations of algorithms. Where in C, one could write a generic list implementation with an element like:

struct element_t {
  struct element_t *next, *prev;
  void *element;
 };

C++ allows one to write something like:

template <typename T>
struct element_t {
   element_t<T> *next, *prev;
   T element;
};

Not only does the C++ implementation prevent common programmer errors (like putting an element of the wrong type on the list), it also allows better optimization by the compiler! For example, a generic sort implementation is available in both C and C++ -

the C routine is defined as:

void qsort(void *base, size_t nmemb, size_t size,
           int(*compar)(const void *, const void *));

whereas the C++ routine is defined as

template void sort(RandomAccessIterator first, RandomAccessIterator last);

The difference being, that for example sorting an array of integers, would, in the C case, require a function call for every single compare, whereas the C++ implementation would allow the compiler to inline the integer comparison calls, as the actual sort routine is automatically instantiated at compile time by the compiler, with the correct types inserted in the template arguments.

A bigger standard library  C++ allows the full use of the C standard library. This is very important of course, as the C standard library is an invaluable resource when writing real world programs. However, C++ includes the Standard Template Library. The STL contains a number of useful templates, like the sort routine above. It includes useful common data structures such as lists, maps, sets, etc. Like the sort routine, the other STL routines and data structures are "tailored" to the specific needs the programmer has - all the programmer has to do is fill in the types.

Of course, the STL is no silver bullet - but it does provide a great help very often, when solving general problems. How often have you implemented a list in C? How often would an RB-tree have been a better solution, if only you had had the time to do it? With the STL you do not need to make such compromises - use the tree if it's a better fit, it's as easy as using the list.

Ok, so I've only been discussing the good parts. Are there any downsides? Of course there are. However, their number is shrinking day by day.  Let me explain:

There are no good C++ compilers It's been like this for a long time. But you must remember, that the language was standardized in 1998 - it is a complex language, more complex than C. It has taken a long time for compilers to catch up to the standard. But as of this writing, there are good compilers available for the most widely used platforms out there; GCC in versions 3.X are generally very good, and it runs on GNU/Linux and most UNIX platforms. Intel has a good compiler for Win32 - it is also pretty good, but unfortunately it still relies on the MS STL which is sub-par.

People don't know good C++ This is not an often heard complaint, but it's something that I see a lot. C++ is a big and complex language - but it also used to be a language that was hyped a lot, especially back in the "OOP solves hunger, cures AIDS and cancer" days. The result seems to be that a lot of really poor C++ code, basically bad C with a few class declarations here and there, is out there and is being used as learning material. This means a lot of people who believe they know C++ actually write really crappy code. That's too bad, and it's a problem, but I think it's unfair to blame this on C++.

So, the only two major problems with C++ are results of C++ being a young language. In time they will vanish. And for most problems out there, if you can get good programmers (or learn good C++ yourself), the problems are not really an issue today.


答:
I think Scala with Akka is a good choice.

Scala has an excellent collections library, featuring immutable collections (a good choice for concurrency) and parallel collections (not the same thing as concurrency, but it might help anyway). Mind you, it does have mutable collections as well if you need them.

On the tools and libraries wiki I see a mention to one Menthor, which is supposed to do parallel and concurrent graph processing. It's hosted on Heather Miller's EPFL page, and Heather is one of Scala's committers.

There's also Graph for Scala, a Graph collection which seems to be fairly used. You might collaborate on this project, perhaps, extending it with your needs.

And, of course, JVM has Neo4J, a graph database. If you have to solve distributed graph problems, perhaps you just need Neo4J. And, then, there's Twitter FlockDB, which targets pretty much the same space. Both of them have nice libraries for Scala.

And, finally, we get to Akka. Akka provides support for the actor concurrency model, which is a pretty good one. But it doesn't stop there! It has Clojure-like Agents (which are not like DAI agents), Software Transactional Memory, and many more features.

So, overall, I think Scala is a great choice.


问:
How can I bootstrap a software development community at my school?
I'm a student at the University of South Florida who's frustrated with the educational environment in the Computer Science program. Right now, I'm taking "Program Design." I should be learning how to organize my source code into functions and modules in order to make my programs readable and maintainable; instead, I'm learning about arrays and recursion in C. Next semester, I have to take "Object-Oriented Design," which is taught through C++ (shudder.)

Two years ago, I fell in love with programming, and I've been learning as much as I could since then. The prospect of taking another C++ class bores me almost to tears. For that reason, I thought I would start a programming club in order to meet similarly ambitious students, learn new languages, discuss software development topics, and work with other students developers.

However, I'm beginning to realize that there may not be any other students who share my software development experience. It's not because of a lack of motivation but a lack of opportunity: I know of only one other programming class ("Programming Languages") and no classes on real-world software development. Everybody else only has experience writing trivial scripts in C and C++.

I've realized that if I want to work with other student software developers, I'm going to have to train them myself. Now, I'm planning to make the club a software development bootcamp, teaching members how to develop software with modern tools and languages. Obviously, starting an unofficial software development course is a monumental task with many possible approaches. My question to you, dear reader, is

What's my plan of attack?

Should I

lecture the club myself, trying to balance club work with homework?

ask the CS faculty to teach on topics within their expertise which may be less than relevant to members?

try to find a sympathetic, experienced developer inside or outside the school who can share my workload?

show video lectures (from MIT OpenCourseWare, Google Tech Talks, etc)?

hold hands-on programming workshops?

assign homework?

do something else?

答:
Since everyone in your club is coming voluntarily, you need to make it interesting and motivating. And homework isn't exactly motivating.

Teaching anybody is hard, but why not try teaching in a hands off kind of way with a goal at the end? Essentially at first you get everbody together and come up with a group project and a language. The project needs to be interesting and be able to show visible progress but not too hard. Once you've got the language nailed down, you teach them the basics (syntax, packages/namespaces, classes, static/dynamic typing, etc). You then give them resources (books, online tutorials, online documentation), an easy way to get a hold of you, and a specific part of the project to work on. Each person then works on the project in their spare time, consulting the documentation and you as needed.

What's the advantage of this process?

People don't get bored listening to you or somebody else drone on about something every single meeting

People learn how to self teach, a very important real world skill

You aren't overcommitting yourself since you aren't the sole resource of knowledge

You don't have to know the whole language before you can teach it since you only need to introduce them to the language. And when they need to ask you about something, you can quickly research it. You do however need to be a little ahead of everybody else, since some things require knowing what's 5 steps ahead

You're creating something, which tends to motivate people

The only way to see if it works is to try it out.


问:
Multiple possible jsp views for a request
I'm looking to offer the user some way of changing how a single page looks based on some pre-defined jsps.

i.e. Two or more jsp's contain similar information, and would be backed by a single controller method. The controller would decide which view to return.

Is there a common way of achieving this?

At the moment I have some administration screens where I control a list of possible views. The user can then choose which one to see from a drop-down.

My current issue is that I don't know how to confirm (at the admin screen) that the view is valid.

Is there a way of asking spring for all possible views so I can filter them and resent a drop-down on the admin screen rather than a free text field? If not is there a way of asking spring if a single view is valid?

All these views will reside under a common directory, so it would probably be possible to scan recursively from that point and build a list of possible views.

This goes beyond simply changing the css, since the page content might be different despite being backed by the same model.

答:
I think this needs some File system scanning in the back end at sprig container and Ajax calls in the Admin Screen this both combined will give you a solution I suppose.

My solution would be, when the client hits the Admin screen and tries to change the view then send the Ajax call to the server, The server instantly scans the list of all Views in the directory, (This is a "File" based scanning as you have explained) and returns Names of the views removing the extensions and in User readable format. (The view names should me user readable).

Try this.
Ramakanth


答:
There have been some trends in the Java world -- particularly the absolutely brilliant adoption of JRuby and Rails or Groovy and Grails -- that indicate that Java still has a lot of life in it. Then there's the Android situation, which is also in Java's favor. As recently as Snow Leopard on Mac, certains changes -- now supporting Midi with no external drivers -- make it so that it's also gaining in possibilities on the desktop. And Swing apps finally look 99% native (or at least there are a lot of nutcases that believe this now: 10 years ago there were none).

Java had an amazing moment in the 90s where it seemed like it was the solution for everything. Now it's clear that nothing is the solution for everything. .Net is kicking ass, and Ruby, and Python, and PHP (with goofy CMS solutions and entire frameworks that people get married to for life!), and Java (with Groovy JRuby JPython whatever), and a whole bunch more. The answer is:

Expect a Pluralistic Universe

Will Java continue to play a major role in this Universe? If you mean "languages that run on the JVM" the answer is most definitely. If the answer is just Java (language, JVM, etc.), then the answer is "maybe not so major." But come on, even Cobol is still hanging in.

Title: Will Java still be relevant in 5 years?


问:
What are the difference between an edge case, a corner case, a base case and a boundary case?
I'm not a native English speaker. In my native language I'm aware of some terms used to refer to the condition checked to stop a recursion, and to the condition checked for extreme, unlikely or super-simple cases. In English, I've encountered the terms "edge case", "corner case", "boundary case" and "base case", but I can't quite figure out the differences and which is used to refer to what; I'd love to get some summary of the differences between them.

In particular, I would be very happy if someone could provide annotations for the lines in the following code sample:

```<code>    int transmogrify(int n) {
1.      assert(n <= 1000000);
2.      if (n < 0) return -1;
3.      if (n == 1000000) return PRE_CALC;
4.      if (n == 0) return n+1;            // For stopping the recursion
5.      if (n == 1251) return 3077;
        return transmogrify(n-1);
    }
</code>```

I think it's:

Sanity check

Input check

Boundary case? Edge case? Corner case?

Base case? Boundary case?

Corner case? Edge case?

答:
I'm not a native English speaker either. But according to Wikipedia:

Edge case occurs at an extreme (maximum or minimum) operating parameter.

Corner case occurs outside of normal operating parameters, specifically when multiple environmental variables or conditions are simultaneously at extreme levels, even though each parameter is within the specified range for that parameter. (The "outside normal operating parameters" obviously means something like "outside typical combination of operating parameters", not strictly "outside allowed operating parameters". That is, you're still within the valid parameter space, but near its corner.)

Boundary case occurs when one of inputs is at or just beyond maximum or minimum limits.

Base case is where Recursion ends.

So, the nomenclature seems to be totally confused, even though corner case seems to mean something a bit different (a combination of values) than edge and boundary cases, which are definitely synonymes. It's probably safe to say that edge, corner, and boundary cases are the same thing in common speech. Someone could mean to say different thing by each of them, but there's hardly any common agreement.

Your 1) and 2) are what you wrote, 3) is a edge/boundary case, 4) is a base case, and 5) is a special case.


问:
Using Scrum/agile with multiple customers
I am a big believer in agile development. I just changed jobs, and I am now working for a company that coordinates big development projects for (rather large) groups of customer organizations. My job is to find the right contractors for the projects, and make sure that the customer organizations are as happy as possible, and control the process. There is nothing in the world that would make me happier, than if I could introduce Scrum or a similar agile method into this situation, making my company's main role the product owner. It would make sense on so many levels.

There are some issues though: Since Scrum is a rapid-response method, I wonder if Scrum is the right method for a place like this, where not one customer but a big group of customers have to be involved in prioritizing of the backlog from sprint to sprint. It takes place in a quite political environment. What pitfalls and possibilities do you see in a situation like this? Can this situation simply be handled by longer sprints?

There is a general understanding and empathy for the agile agenda in the company, but the issue I describe here seems to be a major obstacle.

I would really appreciate your input. I need good ammo for my agile preaching :o)

答:
You need a product owner.  You need a single customer(and preferably a single BA from that customer) that can take responsibility for the direction of the project and coordinate your story priority and champion the end product.   That product owner would be responsible for taking all of the differing customer expectations pulling them together and either getting a consensus from the customers on the priority and direction and/or making the decisions.  </p>

<p>I have heard of some issues with some groups that have multiple customers about competing BA's that want their name on every story and competition for points.  It is important for the scrum master to communicate that this is a business project not a football game.  The points are an indication of progress not a score of how well some one is doing or how much work any one person is doing.  0 point stories and chores are often just as important to the end product as the 5 point stories.  </p>

Body:
You need a product owner.  You need a single customer(and preferably a single BA from that customer) that can take responsibility for the direction of the project and coordinate your story priority and champion the end product.   That product owner would be responsible for taking all of the differing customer expectations pulling them together and either getting a consensus from the customers on the priority and direction and/or making the decisions.

I have heard of some issues with some groups that have multiple customers about competing BA's that want their name on every story and competition for points.  It is important for the scrum master to communicate that this is a business project not a football game.  The points are an indication of progress not a score of how well some one is doing or how much work any one person is doing.  0 point stories and chores are often just as important to the end product as the 5 point stories.


答:
You present an interesting problem primarily because I have never heard of a company operating in such a way.  Many companies have multiple clients, and many also have a single product that they sell to multiple clients with differing needs.

The fact that your organization simply allows clients to brawl it out in a gladiator pit over which features make it into the backlog sounds like a chaotic mess.  Your company NEEDS a product owner who deals with the clients individually and determines what features and changes need to occur in the product to make the majority of clients happy the majority of the time.

The very thought of multiple product owners is inherently Anti-Scrum.

Title: Using Scrum/agile with multiple customers

Body:
I am a big believer in agile development. I just changed jobs, and I am now working for a company that coordinates big development projects for (rather large) groups of customer organizations. My job is to find the right contractors for the projects, and make sure that the customer organizations are as happy as possible, and control the process. There is nothing in the world that would make me happier, than if I could introduce Scrum or a similar agile method into this situation, making my company's main role the product owner. It would make sense on so many levels.

There are some issues though: Since Scrum is a rapid-response method, I wonder if Scrum is the right method for a place like this, where not one customer but a big group of customers have to be involved in prioritizing of the backlog from sprint to sprint. It takes place in a quite political environment. What pitfalls and possibilities do you see in a situation like this? Can this situation simply be handled by longer sprints?

There is a general understanding and empathy for the agile agenda in the company, but the issue I describe here seems to be a major obstacle.

I would really appreciate your input. I need good ammo for my agile preaching :o)


问:
Is "Computer Science != Software Engineering" an excuse to teach programming poorly?
We've all heard it; whenever there's a discussion about CS grads having poor development skills someone eventually says,

Computer science isn't software engineering.

The problem that I see is that programming and software development are taught in CS courses. They're just commonly taught poorly. If it's being taught, then why not teach it right the first time? *

So I would like to see what the opinions are on 2 questions:

Is the CS != SE argument a copout or excuse for not properly teaching programming skills.

Regardless of your answer to question 1; if you were in the almighty position of making such a decision: would you force an emphasis on proper teaching of programming in CS courses?

*. I have a suspicion, based on anecdotal evidence I obtained throughout my education, that most academics in the field haven't had to write code to be maintained and haven't maintained code, and as a result don't have the knowledge/skills to teach it effectively.

答: From my own experience (I'm a student at the moment), I've gotta say yes,it is an excuse. Everybody refers to CS as a science that teaches us all the basics of computers, and SE as a special branch in CS that is explicitly teaching programming. Imo, everyone that has BS in CS, has to know how to write good and optimized code (even if programming isn't his/her speciality area). So yes, if I had a almighty position of making such a decision I would force the students to gain good programming skills.</p>


答:
Regardless of the differences between the words, what you'd use to describe a test depends on the semantics (meaning) of the test, not the exact code - In the example provided it's not obvious what each of the tests mean. That aside, here's how I understand them:

Sanity check = Does this even make sense? For example, if your application only outputs integers, sqrt(-1) and log(-1) are undefined.

Input check = Tests the user input, as opposed to some internal data structure or the output of a function. For example, in Bash [ $# -gt 0 ] checks that you got at least one input parameter, which could also be a sanity check for a command like find or mail.

Edge / Boundary check = The maximum or minimum input which is expected to produce correct output. For example, a function which just adds one to a number will have an operating range from <MIN_INT> to <MAX_INT> - 1, since input smaller than <MIN_INT> can't be provided by the user and output larger than <MAX_INT> won't be useful.

Corner case check = A more complex boundary check (a corner is a two-dimensional boundary), for example combining <MIN_INT> and <MAX_INT> in a calculation.

Special case check = Non-obvious, non-boundary special values, for example log(1 + the smallest floating point number).

Title: What are the difference between an edge case, a corner case, a base case and a boundary case?

Body:
I'm not a native English speaker. In my native language I'm aware of some terms used to refer to the condition checked to stop a recursion, and to the condition checked for extreme, unlikely or super-simple cases. In English, I've encountered the terms "edge case", "corner case", "boundary case" and "base case", but I can't quite figure out the differences and which is used to refer to what; I'd love to get some summary of the differences between them.

In particular, I would be very happy if someone could provide annotations for the lines in the following code sample:

```<code>    int transmogrify(int n) {
1.      assert(n <= 1000000);
2.      if (n < 0) return -1;
3.      if (n == 1000000) return PRE_CALC;
4.      if (n == 0) return n+1;            // For stopping the recursion
5.      if (n == 1251) return 3077;
        return transmogrify(n-1);
    }
</code>```

I think it's:

Sanity check

Input check

Boundary case? Edge case? Corner case?

Base case? Boundary case?

Corner case? Edge case?


答:
1. When to treat a software as deployed and when to start charging for maintenance ?

When the Statement of Work is complete, the job is done.  If you don't have an SoW, you're being too informal about building software for others, and you'll inevitably get into disagreements with your customers, and possibly get threatened with lawsuits.

Anything not covered in the SoW is outside the scope of the paid-for project.  If you choose to do it anyway, it's usually a good idea to make sure the customer knows you're giving them a freebie - customers like freebies, and it reminds them that the next one might cost them.

2. How to charge for software maintenance ?

18% of the then-current purchase price is a common Annual Maintenance Fee for purchased software.  Some vendors succeed in getting as much as 20%, but more than that is unusual.  If you structure your maintenance this way, the customer generally gets whatever you do, regardless of how much or how little time it takes.

The other way to go about it is the way lawyers do - you ask for a retainer, which is really just a pre-payment for work at an established hourly rate.  If the work doesn't consume that many hours, the customer gets the overpayment back.  If the work would exceed it, you talk to the customer about an additional payment - sometimes in advance, sometimes in arrears.

3. How to charge for non-application specific improvements ?

If you charge an Annual Maintenance Fee, that usually includes any other Enhancements and releases you make as well.  In fact, such fees are usually called "M&E" in the software business - "Maintenance & Enhancement" - for just that reason.  It's not a "free upgrade", it's part of what the customer is paying for.

4. How to charge for maintenance in case of hourly contracts ?

See my answer to #1.  If you have a Statement of Work, it's easy to see what's in and out of scope, and negotiate the results.

Title: Evaluating Software Maintenance

Body:
1. When to treat a software as deployed and when to start charging for maintenance ?

In most of the cases the software we make is deployed on the web at early stages to enhance the testing process from the client side. This means that bugs keep arising and we keep fixing them alongside development. Not just that, as the clients use it, they come to know of modifications required which creates a pile of extra work for us. Because of no demarcation line between development, deployment and maintenance stages its hard to understand when to charge for what.

2. How to charge for software maintenance ?

I read that vendors charge 15%-22% generally for softwares annually. That being a fixed fee what happens if the maintenance takes more time then expected ? What happens if the system runs fine or without issues for an year ? Does the client still pay maintenance ?

3. How to charge for non-application specific improvements ?

We use a core engine to build business applications. Improvement in that engine means improvements, new functions, etc can be made available to all clients without modifying their application layer. Should that be included in maintenance as free upgrades ?

4. How to charge for maintenance in case of hourly contracts ?

If we work on an hourly project most of the times the scope of the project keeps expanding but that doesn't require a revaluation of the project because the increase in scope equates to increase in hours and hence increase in budget. But most of the times due to increase in the scope the bug fixing and maintenance work also gets included in the development time. Is that good ? Or should there be a demarcation between deployement and maintenance even for hourly projects ?