问:
Recommendations for implicit versus explicit line joining
I would like to know recommendations about Implicit Line Joining versus Explicit Line Joining in Python.

In particular, do you favor one form over the other? What do you recommend as the general default?  What criteria do you have for choosing one over the other, and if you do have a preference of one, when do you make exceptions for the other?

I have an answer in mind for this question that reflects my own biases, but before I post my own answer I would like to know what others think... and if you can have a better set of criteria than what I have in mind, then I'll certainly accept your answer over my own.

Some of the recommendations may be generalized to this choice in other programming languages, but my own bias is somewhat stronger in Python due to some language-specific features, so I'd like to know both the general and the Python-centric reasoning you may have on this topic.

For some background, the discussion happened around a particular question on stackoverflow, but I thought it was more appropriate to move the discussion over to here as a question to avoid cluttering up the answer on SO with this tangent since it has veered off-topic from the original question. You can look at that question and its answers for the example code snippets that got the discussion going.

Here is a simplified example:

```<code>join_type = "explicit"
a = "%s line joining" \
    % (join_type)
# versus
join_type = "implicit"
b = ("%s line joining"
     % (join_type))
</code>```

答:
Presently, I would prefer

```<code>join_type = "kiding"
a = "%s line joining" % (join_type)
</code>```

B-))

.

I tend to prefer Explicit Lines Joining because I don't like the clutter of parens at the end of expressions.

But I like Implicit Lines Joining to reduce the width occupied by the writing of a string.

Then in some cases, I am embarassed to not mix the two ways

OwnerDisplayName: aculich

Body:
Presently, I would prefer

join_type = "kiding"
a = "%s line joining" % (join_type)

B-))

.

I tend to prefer Explicit Lines Joining because I don't like the clutter of parens at the end of expressions.

But I like Implicit Lines Joining to reduce the width occupied by the writing of a string.

Then in some cases, I am embarassed to not mix the two ways

OwnerDisplayName: eyquem


答:
There is a coding style document called PEP8.  It recommends against the usage of \<NL> wherever parentheses can be used.

The preferred way of wrapping long lines is by using Python's implied line
  continuation inside parentheses, brackets and braces.  Long lines can be
  broken over multiple lines by wrapping expressions in parentheses. These
  should be used in preference to using a backslash for line continuation.
  Make sure to indent the continued line appropriately.  The preferred place
  to break around a binary operator is after the operator, not before it.

Full text: http://www.python.org/dev/peps/pep-0008/ (section Code Layout)

It is not compulsory but it defines acceptable good practices which are especially useful if you have multiple Python committers on your team.

ContentLicense: CC BY-SA 3.0

Title: Recommendations for implicit versus explicit line joining

Body:
I would like to know recommendations about Implicit Line Joining versus Explicit Line Joining in Python.

In particular, do you favor one form over the other? What do you recommend as the general default?  What criteria do you have for choosing one over the other, and if you do have a preference of one, when do you make exceptions for the other?

I have an answer in mind for this question that reflects my own biases, but before I post my own answer I would like to know what others think... and if you can have a better set of criteria than what I have in mind, then I'll certainly accept your answer over my own.

Some of the recommendations may be generalized to this choice in other programming languages, but my own bias is somewhat stronger in Python due to some language-specific features, so I'd like to know both the general and the Python-centric reasoning you may have on this topic.

For some background, the discussion happened around a particular question on stackoverflow, but I thought it was more appropriate to move the discussion over to here as a question to avoid cluttering up the answer on SO with this tangent since it has veered off-topic from the original question. You can look at that question and its answers for the example code snippets that got the discussion going.

Here is a simplified example:

```<code>join_type = "explicit"
a = "%s line joining" \
    % (join_type)
# versus
join_type = "implicit"
b = ("%s line joining"
     % (join_type))
</code>```

OwnerDisplayName: Mischa Arefiev


问:
How do you encourage your organization to move from Java to Scala?
Has anybody's organization started the migration from Java to Scala? If yes, how do you do that? What can I do to encourage my colleagues to do the same?</p>

答:
Have your boss read experiences like this:

I'm currently doing most of my things in Scala right now. (I should
  mention that I think that Scala is the
  best thing since the invention of the
  wheel some time ago. :-D )

In my humble opinion it is the only
  language which truly allows people to
  choose the best approach to a task
  without some unnecessary divide
  between (more) object-oriented and
  (more) functional approaches.

Looking at the languages which
  claimed something like this before, I
  can basically see two competing
  language design camps:

The ones from the object-oriented side which saw that functional
  programming gained some traction
  lately and thought "Well, we don't
  really understand that functional
  thingie, but let's add some fancy
  syntactical sugar to our language, so
  we can claim it is functional too!"
  (examples: Java, Python)

Then the ones from the functional side, who thought "Well, our
  functional approach is far superior to
  anything else and that object-oriented
  nonsense is annoying, but let's put
  some additional keywords into our
  language, that will make our language
  escape academia for sure!" (examples:
  F#, OCaml)

Scala's designers unified many
  approaches coming from both sides and
  created some well-designed language,
  which is - in my humble opinion - the
  biggest difference to other languages,
  which decided to take the
  "Frankenstein" approach to programming
  language design.

Having done only smaller things with Lift yet and only superficial
  experience with Rails and Django, I
  have to admit that most of the time
  when I wondered why something in Lift
  worked differently from what I
  expected, this was due to the fact
  that my expectations were flawed and
  Lift's approach superior.

Lift is certainly no "easy
  introduction to Scala" but learning
  how Lift works was almost as rewarding
  as learning Scala before it.

The ability to have a "clean" view
  without any logic in it is a great
  improvement to other frameworks which
  claimed the same, but fell short of
  it. Scala's XML literal support makes
  it possible to verify the
  well-formedness of your response: The
  compiler will prove at compile time
  that you only emit well-formed XML to
  a client.

Lift is viable technology and at the moment the only real approach if
  you want to build web applications
  which look, feel and behave like
  "real" desktop applications without
  writing insane amounts of code
  yourself.

[ Source ]

ContentLicense: CC BY-SA 2.5


答: I tend to use implicit line joining because I find it more readable and the support from editors is usually better with regard to indentation and highlighting of the whole expression thanks to parenthesis matching.</p>

OwnerDisplayName: jcollado


问:
How to Write Unit Tests When One Fix Will Make Many Failing Tests Pass?
I have two test cases to test a fix to code that is using the wrong criteria for selecting objects from a collection:

Given one object in the collection matching the bad criteria, ensure that no object is returned.

Given two objects in the collection, with the later one matching the bad criteria, ensure that the earlier object is retrned.

Right now, both of these tests will fail.

The problem is, as soon as I make the fix, both tests will pass.

Is this ok? I thought we needed a single failing unit test before writing the code. I haven't heard it's ok to have multiple failing unit tests before writing code.

答:
In our test cases we try to write them in 3 sections (where appropriate)

Setup

Test Execution

Assertion

Sometimes section might be missing but in overall they cover most of the test cases.

In your case it's perfectly OK for a few test to fail if feature doesn't work - the main thing will be to understand the difference and similarity (what different is tested and why tests are failing together). As a solution we've chosen a proper test naming convention that is:

MethodBeingTested_ParametersOrTestCriteria_ExpectedResult()

Then your two tests would be named like

```<code>Method1_1BadObject_ReturnsNoObjects()
Method1_1BadObjectAnd1GoodObject_ReturnsGoodObject()
</code>```

I know that using underscores is a tough decision but it works just perfect for us. You can just glance at the failing test and identify what was expecting and what is failing.

If they both fail it is clear that Method1 is the reason.

Body:
In our test cases we try to write them in 3 sections (where appropriate)

Setup

Test Execution

Assertion

Sometimes section might be missing but in overall they cover most of the test cases.

In your case it's perfectly OK for a few test to fail if feature doesn't work - the main thing will be to understand the difference and similarity (what different is tested and why tests are failing together). As a solution we've chosen a proper test naming convention that is:

MethodBeingTested_ParametersOrTestCriteria_ExpectedResult()

Then your two tests would be named like

Method1_1BadObject_ReturnsNoObjects()
Method1_1BadObjectAnd1GoodObject_ReturnsGoodObject()

I know that using underscores is a tough decision but it works just perfect for us. You can just glance at the failing test and identify what was expecting and what is failing.

If they both fail it is clear that Method1 is the reason.


问:
What's a RESTful url for a linked item?
This is going to be a web service that returns a JSON object. Currently, I'm using C# technology and simply using ASP.Net MVC to create the calls. This is not a web page, so SEO is not a concern.

I've come across a number of instances where I want to get the "next" or "previous" item in a list.
For example, I've got a service that returns a featured photo.
http://myservice.com/photos/123
which returns a JSON

```<code>{"name": "At_The_Concert", "id": "123", "src": "http://myservice.com/photostore/123.jpg"}
</code>```

The client (Ajax, Mobile device, etc.) of this service wants to know what the “next” item is going to be. I’m struggling about what the url should be.

http://myservice.com/photos/123/next

http://myservice.com/photos/next/123

http://myservice.com/nextphotos/123

or maybe the id property should just be a parameter

http://myservice.com/photos/next?photoId=123

Or maybe this is entirely wrong and it should be like

http://myservice.com/photos/?method=getNextPhoto&photoId=123

though with .Net's routing, it might be easier to write it as
http://myservice.com/photos/method/getNextPhoto?photoId=123

I’m relatively new to web services and REST. I get the basic CRUD for REST, but I don’t know what is the best practice for creating more custom urls, in this case the “next” photo.
Is there an accepted RESTful practice?

答: Another option is to look at OData and Service Operations it will guarantee RESTful style of your calls.</p>

Title: What's a RESTful url for a linked item?

ContentLicense: CC BY-SA 4.0


问:
Is cloudera hadoop certification worth the investment
I am considering investing time to learn Hadoop and it's related technologies. The problem is that my current day job will not be using Hadoop any time soon and even if I learn from books, blogs personal projects I will not have much to backup when I actually need to show that I have Hadoop experience.

So while continuing my job I would like to invest into my own training and I am thinking about Hadoop certification from cloudera. What do you think about it?

Please answer from your perspective (if you took the certification and training course or are in the market for hiring new hadoop developers and what do you look for)

I am sure that there is no shortcut to becoming an expert in Hadoop, but certification and training seems like a jump start.

答:
As with many complex technologies, Hadoop can be a challenge to learn on one's own.  That is one reason that Cloudera's training courses are so popular.  The courses for Developers, Administrators and Analysts are all hands-on courses taught by expert instructors.

The certification provides the ability to prove that one fully grasped the concepts.  It is the only certification for Hadoop and there are thousands of people who have earned the CCDH or CCAH distinction, so it has considerable weight in the industry.  I've seen job postings and recruiters actively looking for folks with the Cloudera certification.  Disclaimer: I work for Cloudera. Please contact us if you have questions.


问:
Struggling as a programmer. Need some advice
I've been a developer now for a number of years. I'm pretty good at what I do and can "get the job done".

But, there is a difference between "getting the job done" and "doing the job properly". Let's use an example.

Recently I developed a web site from scratch. The website runs fine and I've had no issues. Looking through the code I thought to myself that I could have done it better. I could have cut down on my MySQL queries. I could have used MVC making it easier to extend (it does need extending now).

I decided to rewrite the project using CodeIgniter. I like the framework. But I then got sidetracked because to cut down on my MySQL queries I had to learn advanced joins.

And this is the problem. Whenever I do a job properly I'm in a constant learning wheel. And topics such as advanced MySQL joins take time to learn, and then time to implement.

I don't work for a company. I do everything alone. So I'd imagine if I was working as a PHP developer for a company there would be separate teams handling the SQL.

Being solo it's difficult. And sometimes, although my knowledge is advanced I find myself asking question, after question. I probably have a lot of pride in my work. But if I had to work for a company handling complete projects I could imagine projects taking a while because I'd have to learn more and more to satisfy my pride and to ensure I'm doing things "correctly".

I do plan on getting a job after the new year. I need the job security. Which is why I'm asking this question.

What advice can you give in terms of self development and self improvement? Should I worry less? Or maybe look for a job as a PHP developer when I won't be handling SQL queries directly?

答:
Being solo is difficult. In contrast, when you are working with a team of developers, everyone is learning from each other. As part of team, you will pick up a lot of knowledge by working with other developers, and with a lot less effort than when you try to figure everything out on your own.

That said, as a developer, you have to commit yourself to constantly learning. Whether it's reading documentation for new frameworks, or books on development, you have to make a constant effort to keep your knowledge current and growing. However, being part of a team may clarify what area you need to learn about most at any given point in time.

Regarding your point about revisiting your older code, and rewriting: I've found that my own code always represents the best of what I knew at the time I wrote it. Many times I go back to something I wrote years ago, and slap myself on the forehead, when I see how much better I could have done, given what I know now. But that's the nature of experience, you get it after you need it...

Lastly, when you're developing an application, you always need exercise good business sense, to decide when it's best to cut corners to finish more quickly, and when it's necessary to take more time to learn something new which would improve the design and quality of the application.  There's a universe of things to learn in the software world.  Without exercising that kind of good judgement, you could find yourself spinning your wheels learning, thinking, redesigning, but never getting anything done.


问:
Choose code design effort or laziness in Bank world
I've worked for two years in a great Investment Bank.

I made some technical projects with the desire of creating code the most optimized, respecting the adapted good design patterns, SOLID principle, law of demeter and avoiding all sorts of duplicate codes ...

When delivery in production => zero bugs, all has happened as expected.

But, a majority of developers came to me in order to precise that all my code is too complex for reading comprehension. I listened for instance : "make some if and instanceof, forget polymorphism so that it will be very easily to correct emergency production bugs". I didn't prefer to answer ......

Knowing these developers are not curious at all, refusing efforts to understand a good design (for instance, 90% of developers don't know what is a Strategy Pattern and make procedural code and never oo-design because they want, they said, simplicity), my project managers told me that I am really in the wrong way and too idealist for the Bank world.

What would you advise me ? Should I keep desire of really good code or adapt me to majority of developers who are, I repeat it, really not interesting by design code that is according to me, all the beauty of our developer job.

Or in the contrary, should they learn basic OO principles and best-practices to adapt themselves to my code ?

答:
Tough spot. I think you can go two ways in parallel, standing your point and showing will to compromise:

This is about money. As any dev job in fact, but since you emphasize the bank environment, this should work even better ;). Show them that your style saves money. Find an example of how a change in requirements could be done really easily because of your design. Try to find a piece of other code (you have to make sure you don't get too aggressive here, but hey, it's about comparing styles of code) which is prone to break soon, and show them how you don't have to care about such problems because your code is better quality to begin with.

This is about money. What if your coding style in fact costs money? It may well do, if other people spend more time trying to understand your code than what's being saved by proper design. You may be doing the right thing technically and still not contribute positively to the team effort. Also, it's possible to overdo OOP design. I'm with you on the "good design is beautiful" side, but I'm trying to make you aware here of their point of view and how they may actually be right from their perspective. In parallel to the previous point, try to find a spot where you overdid it. That gives you some room to maneuver: You can say, ok, I can be a bit more pragmatic here and there, but look, there's also places where this code is really better. It also helps you get into a more cooperative mindset if you try to put yourself into the other guys' shoes.


答:
This is totally normal and not something you should be worrying too much about. You do need to continually learn new skills, but you also need to learn to prioritise and manage your time. You also need to avoid the trap of unnecessary redevelopment.

The inexperienced programmer will often get drawn into the redevelopment trap:

I didn't write this program perfectly, and now I need to extend or
  alter it. It's going to be a lot of work to modify the existing code due to the way I
  wrote it. I've learnt so much more since then, I'm sure the best thing
  would be to rewrite the whole program. I'm sure I could write it
  much better this time.

There are a number of things wrong with this logic.

it's a lot of work to modify or add to the existing code, but won't it be a lot more work to rewrite everything?

if you rewrite everything there's a good chance you'll make new bugs, & it will take longer than you think (especially if you're inexperienced). Are you considering everything that is involved in writing the system? (remember how long it took you the first time)

you've learnt a lot since you originally wrote the program (so you may be able to improve it), but you'll also have learn more next month/year. What makes you think you won't want to rewrite everything again at some point in the future?

the ultimate test of a program is that it works. Don't you have anything better to do?

It can never hurt to contemplate and plan for a redevelopment. That means consider how you'd want to rewrite your program, and attempt to identify any problems that you'll hit. In this case you would have identified the 'advanced SQL joins' that you now require, and then investigate how they work and learn about them.

If you think you wouldn't have identified the advanced join knowledge gap through planning (without starting the development) then you need to improve your planning skills. Try to think about which part of the plan wasn't detailed enough. You should go into as much detail as necessary until you are sure that the entire system is technically possible.

This approach will allow you to learn ahead of time.

Finally, learning on the job is a normal part of programming. This does not mean, however, that you start a task and then realise you have to stop for a week to learn about, say, basic HTML. You can stop for a few hours to learn about something, but your employer is only paying you to get the job done. Learn efficiently - don't read the introduction and history, just how it works and how it will fit in to your program.  If you have to stop working for days on end to learn how to complete a part of the program, you are doing it wrong.

Title: Struggling as a programmer. Need some advice

Body:
I've been a developer now for a number of years. I'm pretty good at what I do and can "get the job done".

But, there is a difference between "getting the job done" and "doing the job properly". Let's use an example.

Recently I developed a web site from scratch. The website runs fine and I've had no issues. Looking through the code I thought to myself that I could have done it better. I could have cut down on my MySQL queries. I could have used MVC making it easier to extend (it does need extending now).

I decided to rewrite the project using CodeIgniter. I like the framework. But I then got sidetracked because to cut down on my MySQL queries I had to learn advanced joins.

And this is the problem. Whenever I do a job properly I'm in a constant learning wheel. And topics such as advanced MySQL joins take time to learn, and then time to implement.

I don't work for a company. I do everything alone. So I'd imagine if I was working as a PHP developer for a company there would be separate teams handling the SQL.

Being solo it's difficult. And sometimes, although my knowledge is advanced I find myself asking question, after question. I probably have a lot of pride in my work. But if I had to work for a company handling complete projects I could imagine projects taking a while because I'd have to learn more and more to satisfy my pride and to ensure I'm doing things "correctly".

I do plan on getting a job after the new year. I need the job security. Which is why I'm asking this question.

What advice can you give in terms of self development and self improvement? Should I worry less? Or maybe look for a job as a PHP developer when I won't be handling SQL queries directly?


答:
Emergencies happen. You're not perfect and their hands will spoil your code at some point. That unless you never take time off, which, as your GP will confirm, is not good for your health. And leads to higher chances of emitting poor code.

Your code may have an higher quality, (unproven fact) but they have policies. (sure as hell fact)

You've been warned to follow policies, and will be liable of not having followed them. In an emergency situation. In a banking application. I mean, if your goal is ending poor and in jail I can figure out many funnier and more meaningful ways to get the to same result.

You cellmates, though, would be delighted to hear you rambling about the lack of curiosity of your former coworkers.

(then again, your company probably has no internal policies against OO design, but the clumsy handed COBOL-trained engineer that will try to fix your code will make some up out of thin air and, IMHO, in a worst case scenario, he'll have a 40% chance of scoring a critical hit)

Title: Choose code design effort or laziness in Bank world

Body:
I've worked for two years in a great Investment Bank.

I made some technical projects with the desire of creating code the most optimized, respecting the adapted good design patterns, SOLID principle, law of demeter and avoiding all sorts of duplicate codes ...

When delivery in production => zero bugs, all has happened as expected.

But, a majority of developers came to me in order to precise that all my code is too complex for reading comprehension. I listened for instance : "make some if and instanceof, forget polymorphism so that it will be very easily to correct emergency production bugs". I didn't prefer to answer ......

Knowing these developers are not curious at all, refusing efforts to understand a good design (for instance, 90% of developers don't know what is a Strategy Pattern and make procedural code and never oo-design because they want, they said, simplicity), my project managers told me that I am really in the wrong way and too idealist for the Bank world.

What would you advise me ? Should I keep desire of really good code or adapt me to majority of developers who are, I repeat it, really not interesting by design code that is according to me, all the beauty of our developer job.

Or in the contrary, should they learn basic OO principles and best-practices to adapt themselves to my code ?


答:
My understanding is that, for a company investing in hadoop, training the workforce at their expenses is a must. They won't even be looking for already-certified workers. There just ain't enough around. "People who overheard the word hadoop at a conference" will be their typical interview subject.

A certified professional with some experience instead would be a blessing in a pressing situation with deadlines and excrements hitting fans all over the codebase.

The point then becomes: where are those mindless companies investing in hadoop without enough workforce to the point of suddenly needing a urgent fix from from a trained professional?

I suppose most of them are in California, and urgent fixes usually work better if you get to their building, they don't usually open their codebases to telecommuting strangers in a snap.

Title: Is cloudera hadoop certification worth the investment

Body:
I am considering investing time to learn Hadoop and it's related technologies. The problem is that my current day job will not be using Hadoop any time soon and even if I learn from books, blogs personal projects I will not have much to backup when I actually need to show that I have Hadoop experience.

So while continuing my job I would like to invest into my own training and I am thinking about Hadoop certification from cloudera. What do you think about it?

Please answer from your perspective (if you took the certification and training course or are in the market for hiring new hadoop developers and what do you look for)

I am sure that there is no shortcut to becoming an expert in Hadoop, but certification and training seems like a jump start.


问:
Best practices in comment writing and documentation
Commenting nowadays is easier than ever.  In Java, there are some nice techniques for linking comments to classes, and Java IDEs are good at making comment shells for you. Languages like Clojure even allow you to add a description of a function in the function code itself as an argument.

However we still live in an age where there are often obsolete or poor comments written by good developers - I'm interested in improving the robustness and usefulness of my comments.

In particular I'm interested in Java/Clojure/Python here, but answers don't need be language-specific.

Are there any emerging techniques that validate comments and automatically detect either "flimsy" comments (for example comments with magic numbers, incomplete sentences, etc..) or incorrect comments (for example, detecting mispelled variables or the like).

And more importantly: Are there accepted "commenting-policies" or strategies out there? There is plenty of advice out there on how to code - but what about "how to comment?"

答:
This might be controversial, but my advice would be to write as FEW comments as possible.  Use nice, clear class names, variable names and method names instead.  Write your code in the clearest way that you can; and consider this to be the most important attribute of your code (other than that it meets its requirements).  Only write a comment if you've made a method as clear as you possibly can, and you still think it requires further explanation.

And have an organisational practice, that whenever anyone changes a class in any way, they have to make sure the comments are still all correct.

OwnerDisplayName: David Wallace


答:
You're going to have to give in a little if you want to keep working there without constant struggles. A dev group that is all procedural isn't going to accept polymorphism right away. Although they may not be able to design in a O-O manner, they can learn from your code. They may appreciate that some of you code is easier to maintain.

As a side note, you need to ask questions during the interview process to see what development process and coding methodology is used if you think it is important to match your preferences.


问:
Any good examples of visualizations of performance test data?
I run some basic performance tests in C# on simple methods, but there are also legacy monolithic pieces written in C# as well as other languages. So, when testing, I often end up working with a black box that takes a number of parameters. I can write code to get a bunch of sample data out, but making sense of it (e.g. presenting it visually is a challenge). I think that most people will not bother looking at a bunch of data or a bunch of poorly done graphics. It better tell a story at a glance.

I can draw pretty 2d graphs, surfaces, heat maps, surface heat maps, what have you. I am hoping to make the graphics so useful, that, when a somewhat trained eye looks at it, they can say "I think we have a problem there. It should not be that slow when we change from 5 to 10 securities." or "This piece is running 20% longer than last month. What feature is killing the performance now?"

I do not have much experience with presenting complex data in a good way, but I know that clever tricks do exist. Good examples are shown here: http://www.datavis.ca/gallery/timelines.php The Napoleon’s March is a great one, as it packs many-dimensional data onto a 2D piece of paper.

Can you suggest any good examples of how to visualize performance test data?

答:
Regardless of how you present the information, if you're looking for changes, like from one month to the next, I sometimes do blink comparison. i.e. put last month's display and this month's display in exactly the same screen position, and then quickly alt-tab between them. Differences show up easily.

If you want to be fancier, you could do image-subtraction or Xor.


答: I'm not sure about other languages, but python allows you to write doctests which are a form of self-validating comments. Of course, they shouldn't be used in place of real unit testing, but are a quick and easy method of documenting specific functions that may not be as obvious as they should be. They come with the added benefit of being able to execute the comment tests to verify that comments are still correct (at least the portion of them that contain tests).</p>

Title: Best practices in comment writing and documentation

Body:
Commenting nowadays is easier than ever.  In Java, there are some nice techniques for linking comments to classes, and Java IDEs are good at making comment shells for you. Languages like Clojure even allow you to add a description of a function in the function code itself as an argument.

However we still live in an age where there are often obsolete or poor comments written by good developers - I'm interested in improving the robustness and usefulness of my comments.

In particular I'm interested in Java/Clojure/Python here, but answers don't need be language-specific.

Are there any emerging techniques that validate comments and automatically detect either "flimsy" comments (for example comments with magic numbers, incomplete sentences, etc..) or incorrect comments (for example, detecting mispelled variables or the like).

And more importantly: Are there accepted "commenting-policies" or strategies out there? There is plenty of advice out there on how to code - but what about "how to comment?"


问:
Is Agile Development used in Machine Learning and Natural Language Processing?
I've been developing web apps for a while now and it is standard practice in our team to use agile development techniques and principles to implement the software.

Recently, I've also become involved in Machine Learning and Natural Language Processing. I heard people primarily use Matlab for developing ML and NLP algorithms. Does agile development have a place there or is that skill completely redundant?

In other words, when you develop ML and NLP algorithms as a job, do you use agile development in the process?

答:
Maching Learning and Natural Language Processing is somewhat data-driven. Without a continuous supply of high-quality data (which must be re-captured whenever new criteria are added), the software development may miss its intended target.

The customer and product owner may devote a bigger fraction of their time toward test data collection.

The adaptations will depend on:

The balance of time allocated toward "spike" versus "implementation"

spike: open-ended research / exploratory prototyping (where the benefits are possible but not certain, and where priorities are fast-changing)

implementation (where the benefits and costs are somewhat more predictable, but each task unit will take much longer to finish).

Average size of a task unit. How long does a spike take? How long does an implementation take? Unlike typical application development, partial algorithm implementations are usually not runnable.

Whether "canned algorithms" i.e. existing libraries / algorithm packages are available.

When these are available, time spent on "implementation" is reduced (because they're already written) and thus more time will be spent on "spikes".

There will be two feedback loops:

In each iteration, customer and product owner collect/update data periodically (and with better quality / newer criteria) based on business need and developers' feedback.

In each iteration, developers try to improve algorithm quality based on the data available, and the algorithm is packaged into a usable system and delivered at the end of each iteration. Customer and product owner should be allowed to take the beta system elsewhere, redistribute them, etc.

Thus, we see that "data" replaces "features" as the main definition of progress.

Because of the increased importance of "research / spike" in ML/NLP development, there is a need for a more organized approach to spike - something you may have already learned from any graduate research teams. Spikes are to be treated as "mini-tasks", taking from hours to days. Implementation of one algorithm suite will take longer, in some cases weeks. Because of task size differences, spikes and implementations are to be prioritized separately. Implementations are costly, something to be avoided if possible. This is one reason for using canned algorithms / existing libraries.

The scrummaster will need to constantly remind everyone to: (1) note down every observation, including "passing thoughts" and hypotheses, and exchange notes often (daily). (2) Spend more time on spikes (3) use existing libraries as much as possible (4) don't worry about execution time - this can be optimized later.

If you do decide to implement something that's missing in libraries, do it with good quality.

Daily activities:

Reprioritize spikes (short tasks / hours - days) and exchange research notes.

De-prioritize spikes aggressively if yesterday's result don't seem promising.

Everyone must commit a fraction of time on implementation (long tasks / weeks), otherwise nobody would be working on them because they tend to be more boring on tasks.

Sprint activities:

Demo, presentation of beta software

New data collection

Retrospect: data collection criteria / new measures of quality, algorithm satisfaction, balance between spikes and implementations

About the note on deferring optimization: The thought-to-code ratio is much higher in ML/NLP than in business software. Thus, once you have a working idea, rewriting the algorithm for an ML/NLP application is easier than rewriting a business software. This means it is easier to get rid of inefficiencies inheritant in the architecture (that is, in the worst case, simply do a rewrite.)

(All editors are welcome to rearrange (re-order) my points.)


答:
my project managers told me that I am really in the wrong way and too
  idealist for the Bank world.

GTFO!

Time to leave and pity them. Why should you give a fuck? You know it'll cost them money in the long run with their incompetent staff. This ain't a game of technical discussion. This is about politics. Have them train the other developers or GTFO! If you haven't got enough political weight, then GTFO! Search for a company with better practices.

The only reason to stay there is an adequate compensation for your headaches. So they better pay way above average or GTFO! I doubt you can grow there as a software developer as well. Growth in our profession is mostly achieved by working with people who are better than you and who encourage best practices. And the better you are, the higher is your market value to companies who care.

Yeah, I know this ain't one of my usual answers but really, if you can't play the politics game in this company, GTFO.

What would you advise me ? Should I keep desire of really good code or
  adapt me to majority of developers who are, I repeat it, really not
  interesting by design code that is according to me, all the beauty of
  our developer job.

I would not work for a company which wants me to provide suboptimal solutions. I wanna carve my name into the software. I want to be proud of it. I don't write procedural applications in languages based on the OO paradigm. I believe in high quality software and if the company doesn't, I'll GTFO! Hope you got enough "fuck you money".


答:
The problem is that you're working in the wrong place. It sounds like you're a very academically inclined programmer. You won't do well in the environment you're in and it's quite likely that some excuse will invented to get rid of you and your "too complex" code. You may be given junk assignments and/or given poor performance reviews and such until you either leave on your own accord or they have a sufficient rear-covering paper trail to fire you.

I'd recommend that you find a place to work that will value your academic leanings. They're out there. You'll also find some that are on the fence between pragmatic and academic. A job like that may be your best option since that would allow you to invite some chaos into your approach as you help others rein theirs in.


问:
Want to do some damage control
I applied for a job in a company. The initial conversation went well.They sent me an assignment and asked me to write a web application, and send it in a specified time. It seemed fairly simple. I completed and sent it to them. Now my mind is completely revolving on the code that I wrote, and now I feel that, there was one small requirement which I did not fulfill. Before they give the verdict shall I be proactive and admit it. Definitely they will find it and I am certain of it. I can send them email saying that I forgot to add that.
What shall I do? Is there anything I do for damage control?</p>

答: Might as well admit you forgot one of the requirements. If you are certain they will notice, then you have nothing to lose. They might appreciate you being forthcoming about it and if they don't, then it's better that you don't work there.</p>

Title: Want to do some damage control


答: Honestly just forget about it. I doubt they will care that you missed one small bit. The purpose of the exercise was to ensure in general terms that you knew what you were doing. Keep applying for other jobs and don't get too fixated on this particular job.</p>

Title: Want to do some damage control

Body:
I applied for a job in a company. The initial conversation went well.They sent me an assignment and asked me to write a web application, and send it in a specified time. It seemed fairly simple. I completed and sent it to them. Now my mind is completely revolving on the code that I wrote, and now I feel that, there was one small requirement which I did not fulfill. Before they give the verdict shall I be proactive and admit it. Definitely they will find it and I am certain of it. I can send them email saying that I forgot to add that.
What shall I do? Is there anything I do for damage control?</p>


答:
You are leaving out some pertinent details.  Was there a time crunch and that is why you forgot the item?  Did you just think it's a simple app and didn't take the time to write your design down before and reviewing it before sending it in?

What I'm sensing is too much emphasis on something that is already done with.  If you forgot something, let them know, but explain why with a plausable explanation.

Are you quitting the field if you don't get this job?  Do your best whenever you can, but don't let this slow you down or stop you.

I would express the truth, your desire for the position, hope for the best and move on to the next position if it doesn't pan out.

Title: Want to do some damage control


答:
Names/documentation should tell you what you are doing.

Implementation should tell you how you are doing it.

Comments should tell you why you do it the way you do.


问:
What's the best place for a high school programmer to get his work noticed?
I'm a 16 year old high school student, with a passion for computer programming.
I'm in grade 11, and I've been learning it as part of the school syllabus for about 8 months.
I've gone beyond what's being taught at school, and witten a few (reasonably good) applications. The language that I program in is C++, on the windows platform.
Eventually I'd like to major in CS at a good college and then work as a programmer.

The specific questions that I have are:

What is a good place for me to get my work noticed ?

Are there any journals, or publications specifically for young programmers ?

If not publications, then are there any good blogs, or is it just better to start your own ?

Is there anything else, that would help me get noticed as a programmer ?

I've tried to be as objective as possible.

If all this was tl;dr:
What's the best way to get noticed as a young programmer ?

Edit:
I am not looking to get hired straight out of high school
The aim is not to impress the community as a professional programmer.
This is with intent towards college applications where having your work seen and critiqued by other people will improve your application. I am not looking to earn money from what I've written (so far).

答: If you want to get noticed AND make some money I would recommend mobile development on iPhone or Android.  You already know C++, which is a great start.  For native development on iPhone you'll need Objective C, and for Android you'll need Java.  Both are similar to C++ (Java is easier since there's not memory management), and will not be too difficult to learn.  So not only will you write applications that will get you noticed, and make you some money, but you will learn new languages and hot platforms in the process.</p>


答:
Victorian era furniture makers (at least, those whose work we still see today) were real craftsmen, what they made was functional, beautiful, well crafted and designed and built to last a lifetime. However in the last 150 years, the world has changed. Not many people are prepared to pay for such craftsmanship, when cheaper alternatives are more commercially pragmatic when buying a dining room table.

Many programmers want to be the craftsmen of old, unfortunately, commerce dictates that this cannot happen all the time. You have a choice, adapt or leave. There are companies that want craftsmen, but they are massively outnumbered by those that want products that mostly work, cheap and now.

The hint to me that you are not suitable for most commercial software development is the "When delivery in production => zero bugs,". Not even Nasa achieved that with the space shuttles.

The only places where you attention to detail, and therefore initial cost, is likely to be acceptable is level 1 life critical systems - e.g. Avionics/ Aerospace, Automotive, Military and Medical.


答:
One of the most authoritative location to find how to use code comment to generate documentation automatically is surely doxygen. Though there could me more of such tools.

This defines the standard of comment writing which should be followed to automatically generate documentation. However, this gives more of a structure but doesn't validate semantically; for example it can't check if you have used misleading english to describe the purpose of a function!

While, this is the best thing that make comments structured, personally i feel there is more documentation needed to make code more maintainable as such. Some time back there was a question in P.SE Can code be the documentation in open source developer tools? How frequently is it? Of course, This applies to non-open-source projects as well.

To make code more maintainable - it is practically more important that there exists a external documentation that helps create structure of how to treat code, and then comments inside the code should be restricted to see

I think, if you want to define the policies for comment writing you should include as a holistic approach included in the coding standard. See this: What could be some pitfalls in introducing a style guide and documentation generating software in a development team?

Usually a comments constitutes less than 5% of the code. And in practice while code-reviews itself draws much less attentions (over other aspects of development) is is practically difficult that comments are also reviewed.


问:
Best Practice: strategy regarding Website Projects and versioning
What are the best practices and strategy for designing and developing a website?

The key parts I want considered are:

DLL deployment

IIS publishing

project versioning

namespace

Please answer these questions with recommended steps you take for your own web sites.

A sample walk-trough** (Please correct it with yours.)

You make a web Application

You make an IIS version of it

Copy the same to the IIS Web Folder

Copy the exact "Web Application" DLL into the IIS version folder ( or Will you build the wesite DLL here with csc or choose another method )

Add each project separately to the repository

Will anyway having both cause any conflicts (web application and website)?

Do you make separated projects?

How do you ensure that build of website assembly is always updated?

How will you go for versioning of these and sync them?

Moving the website DLL from the web application couldn't be a good idea How do you deal with that?

The most important part of this question for me is the number of projects/solutions you make for a website project.

I guess that probably they are 1 or 2 solutions, and as a professional developer, you will  make them subversioned.

Do you change the namespaces, or assemblies? Will each of them have separated core assemblies? Will you share? If you share, how will you deal with that?

I think conflicts will occur.

Do you use a project as a container of the other one? How will subversioning be?

What I use

VisualSVN is my subversioning choice.

I had 2 projects similar to the formula above; I made a web project with pages, and after that I made a clone of it in the IIS. I fixed some addresses and paths issues and copied also the DLL inside the IIS-Version of the site, but I really do not know this way as a completely practical method because of the conflicts I mentioned.

答:
From the perspective of this professional developer, the best practice is to not use web site "projects" at all. They are weird from the start, different in every way from every other project type in Visual Studio in that they don't have a project file.

I think this makes the entire versioning question much simpler. Source control and CI systems are designed to handle projects. Use a project, and you're doing what's expected. Use a web site "project", and you're swimming against the tide.


答:
Are there any emerging techniques that validate comments and
  automatically detect either "flimsy" comments (for example comments
  with magic numbers, incomplete sentences, etc..) or incorrect comments
  (for example, detecting mispelled variables or the like).

There is a well-know technique - it is called "code-review", and has a sister named "pair-programming". Don't expect anything "automagically" here.

And more importantly : Are there accepted "commenting-policies" or
  strategies out there ? There is plenty of advice out there on how to
  code --- but what about "how to comment?"

"Code complete" contains not only all about how to code, but also chapters on "how to comment", especially on how to write self-documenting code.


答: Before taking such drastic measures like changing your employer, I would try to improve your own ability of explaining non-programmers like you executives why your way of coding is better for the company, and saves them time and money. And also, make sure you did not apply design patterns just for the sake of design patterns - are you sure you did also follow the rules of KISS and YAGNI? (Ok, strategy pattern and polymorphism are no rocket science, give your colleagues some time to adapt and explain them why you choose that approach.)


答:
But, a majority of developers came to me in order to precise that all my code is too complex for reading comprehension

Has it occurred to you at all that they may be right?

I worked with someone who put a lot of effort into writing code which he described as elegant. He spent a lot of time decrying other people's work as not being elegant. When it comes to be necessary to maintain code his code is not the code I would chose to be modifying. It is so precise and exacting that changing it is deeply fraught with danger.

The interesting word you mention here is "complex". Code which can be described as complex can rarely be also described as particularly good.


问:
When must arbitrary precision arithmetic functions be used in PHP?
My colleague uses the Binary Calculator functions in bandwidth calculations; as much as terrabytes, and with percentage splitting on allocation. His usage of these functions appears correct in order not to lose a byte; although he seems to be using them now for everything.

The manual only says:

For arbitrary precision mathematics PHP offers the Binary Calculator which supports numbers of any size and precision, represented as strings.

How much is any size? Is it really necessary? How big is the default float in PHP? Are there any good advice regarding this or things to keep in mind?

答:
The size of integers in PHP is platform dependent.

The size of an integer is platform-dependent, although a maximum value of about two billion is the usual value (that's 32 bits signed). 64-bit platforms usually have a maximum value of about 9E18. PHP does not support unsigned integers. Integer size can be determined using the constant PHP_INT_SIZE, and maximum value using the constant PHP_INT_MAX since PHP 4.4.0 and PHP 5.0.5.

The size of floats, is also platform dependent:

The size of a float is platform-dependent, although a maximum of ~1.8e308 with a precision of roughly 14 decimal digits is a common value (the 64 bit IEEE format).

and there's a big red warning in the manual about float precision:

Floating point numbers have limited precision. Although it depends on the system, PHP typically uses the IEEE 754 double precision format, which will give a maximum relative error due to rounding in the order of 1.11e-16. Non elementary arithmetic operations may give larger errors, and, of course, error progragation must be considered when several operations are compounded.

Additionally, rational numbers that are exactly representable as floating point numbers in base 10, like 0.1 or 0.7, do not have an exact representation as floating point numbers in base 2, which is used internally, no matter the size of the mantissa. Hence, they cannot be converted into their internal binary counterparts without a small loss of precision. This can lead to confusing results: for example, floor((0.1+0.7)*10) will usually return 7 instead of the expected 8, since the internal representation will be something like 7.9999999999999991118....

The BC Math extension bypasses the dependencies, allowing you to explicitly specify a large integer as a string, and avoid PHP's interpretation of integer literals. The GMP functions are also good alternatives and work in similar fashion. We can safely assume that any size refers to the maximum size of strings, which is only limited by available memory:

It is no problem for a string to become very large. PHP imposes no boundary on the size of a string; the only limit is the available memory of the computer on which PHP is running.

Whether it makes sense or not can only be decided on a per case basis. I've never noticed any actual performance issues with the extension's functions, but most certainly they aren't as fast as native alternatives.

Is it really necessary?

It's only necessary when it is, but that's not always obvious. You can easily identify blatant abuse, but can't as easily argue on more complex scenarios.

Discuss with your colleague, and find out why he uses them everywhere. Overflows lead to extremely ugly situations, ones that I find quite difficult to identify and solve. If he's abusing BC Math, it might be just because he got horribly stuck once and tries to play it as safe as possible. Although there's nothing inherently wrong with using BC Math, the otherwise insignificant performance penalty may be a serious issue in several scenarios. If you notice any performance issue, make sure you profile your application and be certain that's BC Math related.

Always remember that your calculations should work correctly:

On every system you're targeting, individual developer machines and (of course) production machine included.

Regardless of possible system/platform upgrades or downgrades.

In multi platform development you should always consider the lowest limit as a hard limit. If you are absolutely certain that your calculations will not go over the limits (including  their results), then there's no point in using BC Math.

But if what you're describing is that he prefers echo bcadd("1", "2"); over echo 1+2;, well, good luck!

I found an extremely interesting & relevant blog post in my huge list of bookmarks, Integers in PHP, running with scissors, and portability, on Percona's MySQL Performance blog. It's old (2007) but it gives a good overview of various snafus with integer portability in PHP.


答:
I would first of all do a check that your way is really better. Object Oriented code can be very nice, but it can also be a nightmare of hidden side effects and every action can require several different classes.

Better yet go to InfoQ and Watch Rich Hickey's talk on "Simple Made Easy"


问:
How do you test a data load?
I'm working on a project that involves loading batches of 3000+ files to several dozen tables.  There is no user interface, and the tables are simply available for querying.  What are the best practices for testing this type of process?

Loading a small set of data and validating each and every member?

Loading all the data and validating a subset?

Loading all the data and validating counts, averages, and other metrics?

Are there other types of testing that can be done, or is some combination best?

答:
I think you want two kinds of tests:

the "positive" set which is sample enough data to validate the tool

the "negative" set which consists of isolated sample cases of the edge cases which broke things and were fixed. These should be built over time.

Strategy presumes real world conditions such as poor specifications and bad data hygiene.

Title: How do you test a data load?


答:
At my company, we conducted a series of workshops based on Clean Code Developer. The purpose was to create a forum outside of the normal day-to-day business with its hectic and deadlines and foul compromises, where developers could learn about software design principles (like you mentioned), programming techniques etc. and reflect on their projects and their own work.

Real-life examples from actual projects were discussed as well. Feedback from the participants was AFAIK very positive. It's hard to measure an actual benefit, though.

Attendance to those workshops was partly on company-sponsored time, partly the participants' own spare time. You won't reach those colleagues who don't care about learning and simply want to do their job and go home, but for anyone else who has some interest in his own work left this might be interesting.


问:
Graduate expectations versus reality
When choosing what we want to study, and do with our careers and lives, we all have some expectations of what it is going to be like. Now that I've been in the industry for almost a decade, I've been reflecting a bit on what I thought (back when I was studying Computer Science) programming working life was going to be like, and how it's actually turning out to be.

My two biggest shocks (or should I say, broken expectations) by far are the sheer amount of maintenance work involved in software, and the overall lack of professionalism:

Maintenance: At uni, we were all told that the majority of software work is maintenance of existing systems. So I knew to expect this in the abstract. But I never imagined exactly how overwhelming this would turn out to be. Perhaps it's something I mentally glazed over, and hoped I'd be building cool new stuff from scratch a lot more. But it really is the case that most jobs are overwhelmingly maintenance, bug fixing, and support oriented.

Lack of professionalism: At uni, I always had the impression that commercial software work is very process-oriented and stringently engineered. I had images of ISO processes, reams of technical documentation, every feature and bug being strictly documented, and a generally professional environment. It came as a huge shock to realise that most software companies operate no differently to a team of students working on a large semester-long project. And I've worked in both the small agile hack shop, and the medium sized corporate enterprise. While I wouldn't say that it's always been outright "unprofessional", it definitely feels like the software industry (on the whole) is far from the strong engineering discipline that I expected it to be.

Has anyone else had similar experiences to this? What are the ways in which your expectations of what our profession would be like were different to the reality?

答: Images of ISO processes, reams of technical documentation, every feature and bug being strictly documented, and a generally professional environment describes my company fairly well.  We do critical infrastructure software/hardware products though, so, well, the pressure is on for quality (we are ISO 9001 certified, for example).

Title: Graduate expectations versus reality


答:
Are there any good advice regarding this or things to keep in mind?

Using the BC Math Functions in PHP has advantages and disadvantages.

Advantages:

you can perform basic calculations on numbers with "numbers of any size and precision".

Disadvantages:

calculation is not native (calculations on Integer or Float is PHP native and often CPU native)

numbers as to be managed as strings

code is not easy to read

So we can see that BC Math is reserved for a specific usage, and may obfuscate the formulas and even the algorithms, and also slow down massive calculations.

So it is a good idea to understand your business calculations to figure out when such functions are really needed and where they are useless. Thus here you have to focus on code speed and code readability. Then it is appropriate to choose the coding convention of the project on the usage of BC Math.

To do so, you have to understand the technical differences between the PHP native calculations and the BC Math Function. That is your questions "How much is any size? How big is the default float in PHP?"

How much is any size?

We cannot find much documentation about his. Probably as long as a string can be in PHP.

How big is the default float in PHP?

"The size of a float is platform-dependent, although a maximum of ~1.8e308 with a precision of roughly 14 decimal digits is a common value (the 64 bit IEEE format)."

More details at the PHP manual.

Note that PHP also give GMP Functions that performs calculations on big Integers.

Title: When must arbitrary precision arithmetic functions be used in PHP?

Body:
My colleague uses the Binary Calculator functions in bandwidth calculations; as much as terrabytes, and with percentage splitting on allocation. His usage of these functions appears correct in order not to lose a byte; although he seems to be using them now for everything.

The manual only says:

For arbitrary precision mathematics PHP offers the Binary Calculator which supports numbers of any size and precision, represented as strings.

How much is any size? Is it really necessary? How big is the default float in PHP? Are there any good advice regarding this or things to keep in mind?


答: I'm all for being proactive and telling them about it. If I were the one looking at your code and I noticed an unfulfilled requirement, it would say something important to me that you not only realized the error on your own, but that you were willing to do something about it.</p>

Title: Want to do some damage control


答:
I think you need to worry less about "getting it done properly". Strive for perfection, but realize that it is not really possible to design a perfect solution, even more so the first time round. The fact that you are worried enough about getting it done properly to ask this question means you are already on the right track.

As for your frustration with learning new things,
I found that working in a group, and being able to ask and discuss the problem with other programmers removed the pain of finding out what it is I needed to learn, and replaced it with the joy of discovering something new and learning how to apply it.

I love writing software, but sometimes there is indeed pain in not the actual learning of something new, but finding what it is exactly that you need to learn to be able to achieve what it is you want to do.

From what I understand, I have been in a similar position to you. Coding something alone can be both frustrating and difficult at times, and rewarding and somewhat fun at other times.

Do exactly what you plan to do, find a job where you will be a part of a team (and do your best to make sure you land a job somewhere that doesn't suck). Working with other people who use the same technologies and design the same software will expand your understanding and application of those technologies and design patterns almost overnight.

As for knowing how to do something right the first time, well, how would you know there was a better way unless you had already done it a certain way the first time? Skill in software design is often largely dependent on experience. Joel Spolsky is a software genius, but if you read a lot of his articles you will notice that they are very much a result of both experience and intelligence.

As for the SQL part, as a .NET developer I've yet to work anywhere that had a dedicated database developer, we all write our own SQL, but there are often developers that are really good at SQL who are willing to help you out with the more in depth stuff.

You sound like a smart guy, I don't think you should be so hard on yourself.


问:
Get attribution when other people use my code
I have this portfolio website containing some personal projects/algorithm implementations. I want to get attribution if and when other people use my code or snippets of it. I initially thought of using Creative Commons but, as CC itself points out, CC doesn't fit well with software/code distributions. I would've used CC0 but CC0 does not enforce attribution.

So, is there a way for me to enforce attribution on my code ala CC? Including a copy of a FOSS license with every code distribution I have seems overkill---the license itself might be longer than some of my codes. Will copyright claims on top of source codes work if I say there that attribution is required?

答:
Don’t include a copy of the license then, just name it, and as a curtesy, provide a link. For instance:

```<code>// This code is licensed under the BSD license.
// The license text can be found at
// http://www.opensource.org/licenses/bsd-license.php
</code>```

This should be fine.

If it’s particularly important to you, separately mention that you’d like attribution for usage of the code.

Body:
Don’t include a copy of the license then, just name it, and as a curtesy, provide a link. For instance:

// This code is licensed under the BSD license.
// The license text can be found at
// http://www.opensource.org/licenses/bsd-license.php

This should be fine.

If it’s particularly important to you, separately mention that you’d like attribution for usage of the code.


问:
Best practices for moving large MS Access application towards .Net?
We have a really huge MS Access application developed in-house initially for our personal needs which then was turned into a commercial software and successfully sold. The software is a sort of "all-round-software-for-your-business" and contains several modules including Document Management System, Enterprise Resource Planning, Inventory Management, Customer Relationship Management, Data Analysis etc. We are quite satisfied with the current functionality of the application, but in order to meet the requests from our clients we realize that we have to move to something new.

We decided to gradually move our application towards .Net because we can stick to Visual Basic .Net: even though it is a new language for most of the developers here, we have deep knowledge of VBA and several dozen small projects implemented in VB6.

We already started moving the data layer functionality of our application to MS SQL Server, so that every data manipulation and search is performed directly on the server.

What we are looking for are best practices for gradually moving our extensive GUI (about 500-600 different forms including subforms, about 200 reports with multi-language support etc). Following the recent request from our potential customer to implement asynchronous data encryption on documents in DMS we would be also happy to completely decouple this part from MS Access and implement it in .Net.

The question is how to seamlessly integrate the .Net application with the existing MS Access system, so that we can invoke it with certain parameters (user rights etc.) and enable data exchange between this application and running MS Access application.

EDIT:

We tried to apply some practices from Martin Fowler's book "Enterprise intergration patterns" to achieve some integration between the MS Access application and some small utilities we implemented in .Net for various needs. But we only managed to use the "shared database" pattern and weren't really satisfied with our solution.

For instance, we implemented a small utility running as a Windows service which automatically downloads all messages from the mail server using POP3 connection and stores them into one table, whereas all attachments are stored in file system.

What we mainly did is we used ADO.NET to directly access MS Access databases in MDB format and populate table with some processed data (like the data about mail messages from the example above: we have fields for FROM, TO, CC, BCC, Subject and Body).

There is absolutely no problem to work with MDB data format from .Net, moreover we don't want to stay with MDB and upsized almost everything to MS SQL Server 2008 -- this gives us much more freedom concerning the data management and scalability.

The main problem here is that we don't know how to implement a sort of "callback" in Access so that we can trigger the execution of certain VBA code on data update.

We had great hopes with MS Access 2010 supporting update and insert triggers for data tables, but it turned out that we can only use MS Access Macros for these triggers and there is no way to execute any custom VBA code within the trigger.

We also tried some solutions with sending keystrokes directly to MS Access window to mimick some user-invoked data requery. This works, but we don't think this is a realiable solution that can be used in production.

We also looked into DDE for MS Access, but we couldn't find any good sample solution implementing DDE commands and using them for in-memory data and command exchange.

So, the main problem is to have MS Access and .Net application co-exist and interact with each other.

EDIT2:

I forgot to mention what we also implemented MSMQ library in VBA for message passing between .Net and MS Access, the problem was again the lack of callback here: we really had to poll the queue for new messages and given that VBA does not really support multi-threading it wasn't really a nice solution.

答: I don't know deep knowledge about your business logic layer, but you can also access your MS Access databases in your .NET application. If it's not simply about fetching data, you can implement a TCP/IP connection between your programs (VB6 and VB.NET applications). Please have a look at an article on CodeProject.</p>


答:
You may think that learning new technologies and problems is a time sink. But don't panic. It's normal. It is part of your practice as a programmer to learn... or else we'd all be stuck with COBOL.

Freelance professionals adjust their commissions accordingly and learning periods is among many other things something that should be factored in to your time estimates. Next time you decide to bring in a new framework, make sure you plan in enough time to learn it.


问:
Automatically adding data from JSON to SQL
I'm really new to this sort of stuff; my background is in C# mainly. Could anyone point me in the right direction?

I need to set a script to automatically parse some JSON into an SQL database whenever the data has been updated on the server.

I look at this file first which returns the file location for the data and the last modified time stamp: http://us.battle.net/api/wow/auction/data/medivh.

I've spent the last hour googling, but I can't find an adequate answer. To summarise, the script needs to run every 15 minutes or so, check if the timestamp changed and if so, and pull the new data and enter it into an SQL database.

Do I need to use PHP to parse and insert the JSON data into the database? If so, how do I manage to run the PHP code every x minutes?

答:
Parsing JSON: Assuming that you are on 5.2.x or above, you can use json_decode to parse the json data.

As for executing the script every x minutes, read up on cron jobs.

Edit: Answer is based on the assumption that you are on Linux and want to do this in PHP.


答: Try to remember that programming is considered by some as a means to an end rather than for the sake of itself. Think of all the products and services you use: do you spend much time considering if the code underneath is made elegantly? Or do you simply appreciate them as they just work? Find an industry or cause you are passionate about, then find an organisation with that, then offer them solutions that include programming but not only that. Problems can be solved brilliantly in different ways.


答: Since you already have a good understanding of the Access object model, I would think that you want to use Access Interop from your .NET app. It should (more or less) allow you to automate control of an Access app, without the opaqueness of DDE.</p>

Title: Best practices for moving large MS Access application towards .Net?

Body:
We have a really huge MS Access application developed in-house initially for our personal needs which then was turned into a commercial software and successfully sold. The software is a sort of "all-round-software-for-your-business" and contains several modules including Document Management System, Enterprise Resource Planning, Inventory Management, Customer Relationship Management, Data Analysis etc. We are quite satisfied with the current functionality of the application, but in order to meet the requests from our clients we realize that we have to move to something new.

We decided to gradually move our application towards .Net because we can stick to Visual Basic .Net: even though it is a new language for most of the developers here, we have deep knowledge of VBA and several dozen small projects implemented in VB6.

We already started moving the data layer functionality of our application to MS SQL Server, so that every data manipulation and search is performed directly on the server.

What we are looking for are best practices for gradually moving our extensive GUI (about 500-600 different forms including subforms, about 200 reports with multi-language support etc). Following the recent request from our potential customer to implement asynchronous data encryption on documents in DMS we would be also happy to completely decouple this part from MS Access and implement it in .Net.

The question is how to seamlessly integrate the .Net application with the existing MS Access system, so that we can invoke it with certain parameters (user rights etc.) and enable data exchange between this application and running MS Access application.

EDIT:

We tried to apply some practices from Martin Fowler's book "Enterprise intergration patterns" to achieve some integration between the MS Access application and some small utilities we implemented in .Net for various needs. But we only managed to use the "shared database" pattern and weren't really satisfied with our solution.

For instance, we implemented a small utility running as a Windows service which automatically downloads all messages from the mail server using POP3 connection and stores them into one table, whereas all attachments are stored in file system.

What we mainly did is we used ADO.NET to directly access MS Access databases in MDB format and populate table with some processed data (like the data about mail messages from the example above: we have fields for FROM, TO, CC, BCC, Subject and Body).

There is absolutely no problem to work with MDB data format from .Net, moreover we don't want to stay with MDB and upsized almost everything to MS SQL Server 2008 -- this gives us much more freedom concerning the data management and scalability.

The main problem here is that we don't know how to implement a sort of "callback" in Access so that we can trigger the execution of certain VBA code on data update.

We had great hopes with MS Access 2010 supporting update and insert triggers for data tables, but it turned out that we can only use MS Access Macros for these triggers and there is no way to execute any custom VBA code within the trigger.

We also tried some solutions with sending keystrokes directly to MS Access window to mimick some user-invoked data requery. This works, but we don't think this is a realiable solution that can be used in production.

We also looked into DDE for MS Access, but we couldn't find any good sample solution implementing DDE commands and using them for in-memory data and command exchange.

So, the main problem is to have MS Access and .Net application co-exist and interact with each other.

EDIT2:

I forgot to mention what we also implemented MSMQ library in VBA for message passing between .Net and MS Access, the problem was again the lack of callback here: we really had to poll the queue for new messages and given that VBA does not really support multi-threading it wasn't really a nice solution.


问:
Has the time gone to think about user with JavaScript disabled in browser?

Possible Duplicate:

Should I Bother To Develop for JavaScript Disabled?

In this Modern time of

HTML5 API

jQuery

Modernizr

HTML5 Shim

Respond.JS

Google Chrome app store

Canvas

Has the time gone to think about user with JavaScript disabled in browser? Ot it's still need to be consider

答:
It is as it has always been, IMO. It just depends if you want to target 100% of the population, or if you don't care about the M % who have a completely outdated browser, and the N % who disable JavaScript.

M and N tend to decrease, and I don't care about them much. But your boss or your investor could be of a different opinion.

I'd find it more important to make an app accessible to disabled persons (who don't have a choice), rather than caring about those who have a choice but choose not to use a modern browser with JavaScript enabled.

OwnerDisplayName: Jitendra Vyas

OwnerDisplayName: JB Nizet


答:
It depends very much on your intended audience.

A personal blog on web development, for example, will have very few visitors with js disabled.

A business website, on the other hand, might have more old-fashioned business executive types who come to visit, and it may be very important to make sure the site is accessible to them. They are the customers, after all!

Body:
Possible Duplicate:

Should I Bother To Develop for JavaScript Disabled?

In this Modern time of

HTML5 API

jQuery

Modernizr

HTML5 Shim

Respond.JS

Google Chrome app store

Canvas

Has the time gone to think about user with JavaScript disabled in browser? Ot it's still need to be consider

OwnerDisplayName: esther h


答:
For web apps, yes, I think it's okay to require JavaScript because it's the nature of web apps to provide a rich, interactive user interface.

More simple websites like blogs, portfolios or brand websites should be able to work without JavaScript, in my opinion. I make all my websites work without JavaScript.

I know a few people who disabled JavaScript or block it with NoScript due to security concerns or because they are annoyed of animations.

Title: Has the time gone to think about user with JavaScript disabled in browser?

OwnerDisplayName: David


问:
How to fit testing in Scrum sprints and how to write user stories in Scrum
I am the development team lead of a new project at my company. This is the first project where the company will use Scrum. We have a waterfall/iterative SDLC. The BAs write requirements docs, hands over to dev and test, dev start developing and will release to testing in iterations. Testers take long time to test a release by which devs continue development but also bug fixes for the current release.
I have a few questions

In a sprint with say 5 stories when do you release for testing ? Is it as soon as a story is completed by dev or after all stories are completed but before end of sprint giving test the required time to test.

If the BA writes user stories what should be the detail. Traditionally it takes long time to write a spec with all UI layout, behaviour, text etc to be finalised. I guess my question is how to write stories that are implementable and testable.

Our test team is non-technical. How important it is to have automated UI testing for Scrum. The UI is based on WPF.

I have solid development experience using agile methods (TDD, code reviews, refactoring etc.) but new to scrum.

edit: By iterations I mean that if there are 100 requirements we may release to testing when we have finished 30, 35, 35 requirements rather than wait till all 100 requirements have been completed.

答:
If testing is separate from development, you have two -- separate -- scrum teams.  It is a bad idea to have one hand work to the other.

Your developers must write their own tests, separate from this other team.  You must treat this other "test" team as your customers.

In a sprint ... when do you release for testing ?

When the sprint is done.  Totally done.  That means you've done your own unit testing and are sure that it works.  After your development team is done, you release it to other teams for "testing" or "deployment" or whatever else happens in the organization.

I guess my question is how to write stories that are implementable and testable.

That varies from team to team.  The BA is part of the development team.  You have to work on that as a team (BA plus developers) to get the right amount of detail.  It's a team effort to get the right information from BA to the rest of the team.

How important it is to have automated UI testing for Scrum.

Essential.  Completely required for any UI development.  The developers must do all testing themselves before it is given to the "test team".  If there's a UI, they must test it.  If there's no UI, then automated UI testing isn't required.  Testing is required, and a UI must be tested.  Automated testing is the current best practice.

Bottom line.  A separate "test" team and a BA who writes every little detail is not an optimal organization for Scrum.  Scrum means you have to rethink your organization as well as your processes.


答:
Most of the answers I am going to give relate to an Agile method of software development versus an Iterative Waterfall method.  Scrum just happens to be a popular Agile implementation.

In typical Scrum there is no seperate testing phase, because formal testing should occur throughout the entire sprint.  As a developer finishes a User Story, the QA resource should already have his/her test cases prepared and begin testing at that point.  If their test cases pass they Accept the user story and move to the next one.  Once all User Stories have been completed and Accepted then the sprint is over and you begin the next one.  This is all of course dependent on Continuous Integration, so development changes are immediately available to QA.  Further development should follow TDD guidelines to ensure regression testing is as quick and painless as possible.

It is a good idea for BA's to write user stories, but for more detailed and specific control, User Stories can accompany formal Requirements documents.  The User Story should be written from the perspective of a single user by role.  It expresses a need from the user's point of view, so quite naturally if the software currently satisfies all aspects of that need then the user story is being met.  User stories can be comprised of child user stories and assignable Tasks.  There may be overlap in Tasks for multiple user stories.

Automated UI testing can be a good thing, but I personally feel that more effort on TDD methods and 100% unit test coverage of all Business Logic is more important.  Most software development teams cannot seem to achieve 100% coverage of Business Logic, so in my opinion Automated UI Testing would be a waste of valuable time that could be used to write more unit tests for BL.  It is a luxury not a need in my opinion.

Title: How to fit testing in Scrum sprints and how to write user stories in Scrum

Body:
I am the development team lead of a new project at my company. This is the first project where the company will use Scrum. We have a waterfall/iterative SDLC. The BAs write requirements docs, hands over to dev and test, dev start developing and will release to testing in iterations. Testers take long time to test a release by which devs continue development but also bug fixes for the current release.
I have a few questions

In a sprint with say 5 stories when do you release for testing ? Is it as soon as a story is completed by dev or after all stories are completed but before end of sprint giving test the required time to test.

If the BA writes user stories what should be the detail. Traditionally it takes long time to write a spec with all UI layout, behaviour, text etc to be finalised. I guess my question is how to write stories that are implementable and testable.

Our test team is non-technical. How important it is to have automated UI testing for Scrum. The UI is based on WPF.

I have solid development experience using agile methods (TDD, code reviews, refactoring etc.) but new to scrum.

edit: By iterations I mean that if there are 100 requirements we may release to testing when we have finished 30, 35, 35 requirements rather than wait till all 100 requirements have been completed.


答:
We decided to gradually move our application towards .Net

Often a mistake.  Best practice is to not try "gradually".

even though it is a new language for most of the developers here, we have deep knowledge of VBA and several dozen small projects implemented in VB6.

Not a very good basis for a decision.  If you want to learn a new language, don't learn VB.  Learn C# or something even better like Java.

"a new language for most of the developers here, we have deep knowledge of VBA" is a common code phrase for "we have a VBA Guru who we don't want to irritate".  That's something that's possibly bad, also.

What we are looking for are best practices for gradually moving our extensive GUI

The best practices don't involve "Gradual".  They involve "Discard Entirely".

The gradual migrations that I've seen have broken down because it's so hard.

You're better off doing this.

Preserve the most valuable asset.  The data.  Move all the data to SQL Server.  All of it.  Rewrite all of the MS-Access to use ODBC connections to SQL Server.  Right now.

Fire anyone who creates temporary tables or data or anything in MS-Access.  All data must live in a database outside MS-Access.  Data in MS-Access is what's causing the problems, so stop now and be sure that everyone agrees.  If they don't agree, find them a new job that doesn't involve hacking in MS-Access while you're trying to get rid of MS-Access.

Find a reporting framework that will automatically generate reports close to what you have now.  No programming.  Just give it a table or a view and bang! it's done.

Enumerate all 500 reports.  Partition them into reports that are easily built with the tool and reports that are harder.   Prioritize the hard ones into "Must Have", "Should Have", Could Have" and "Won't Do Until Later".    Replace the automated reports and the must-have reports this reporting tool completely outside MS-Access.

My experience is that a database view often gets reused in about 20 or so reports.  From that, I'd guess that you have 25 relevant views from which the 500 reports are derived.  Any tool that can automate report production should handle most of your reporting from a small set of well-crafted SQL views.  A few reports will be too complex or difficult for an automated tool.

Find a development framework that builds CRUD transactions automatically.

Partition your 200 forms into CRUD forms (which can be built automatically) and non-CRUD forms.  Among the non-CRUD, prioritize using the MoSCoW (Must, Should, Could, Won't) rules.

Often, 60-80% of an applications forms are simple, automated CRUD forms.
20-40% are more complex and require more skilled programming.  Based on this,
you have 120 to 160 CRUD forms that you don't need to rewrite, just automate.
You have 40-80 seriously complex transactions.

Build the CRUD forms and the Must-have non-CRUD forms.

Evaluate the gaps.  Re-prioritize and start working on the most important parts of the "Should-Have" list.

It's probably easiest to discard Access entirely.  Avoid gradualism.

You're going to spend all the money eventually.

You may as well budget for it and spend it now.

Trying to do this gradually may actually be more expensive because of the complexity of trying to manage coexistence.


问:
Why do programming language (open) standards cost money?
Isn't it counter-productive to ask for 384 Swiss franks for C11 or 352 Swiss franks for C++11, if the aim is to make the standards widely adopted?

Please note, I'm not ranting at all, and I'm not against paying; I would like to understand the rationale behind setting the prices as such, especially knowing that ISO is network of national standard institutes (i.e. funded by governments). And I also doubt that these prices would generate enough income to fund an organization like that, so there must be another reason.

答:
With regards specifically to ISO standards, there is a question/answer in their FAQ that addresses why ISO standards cost money:

ISO standards cost money to develop, publish and distribute. Someone has to pay. The current system whereby users are requested to pay for the standards they use, not only sustains the development process but also, very importantly, ensures that the balance of independent vs. government, private vs. public interests can be maintained.

With regards to other standards organizations, I suspect that Yannis Rizos is correct in his comment and that it is similar to the ISO's stance. It takes a lot of time and effort to develop a standard, and then transform it into a format that is consumable. You are paying for the time and resources that it took to turn that standard into the format that you are using and then have it delivered to you.


答:
Some points:

IIRC, the price of an ISO standard is directly a function of the number of pages in the standard, whatever the standard is.

Programming languages is one of the very few matter for which individuals may want to get a copy of the standard.  For most matters, only companies (and sometimes an handful of them) will want a copy.  And for companies, the price is indeed nominal compared to other costs (such as ensuring that their product comply effectively with the standard -- even for PL, if you are writing a compiler, 300 euros for the standard is what? 1 or 2 days for one person?, and people writing compilers, the standard libraries or books are the market for standard, most other uses aren't really pertinent).

When selling the standards, ISO is in competition with its member. ANSI, AFNOR, BSI, ... are also in the process of selling the documents.  Those won't accept ISO to cut its price too much.  Note that some of them sold the C and C++ for far less (ANSI had the previous version in electronic form at 30$, BSI co-published an hard copy edition; I've not found yet such a source for the latest version)

People of the committee are already contributing quite a lot of the costs (sometimes there is a fee, and then their time, they travel of their own expense, they provide sponsorship for the meetings)

Other standardization may be cheaper to get but participation can be more costly (ECMA gives freely its standards, but the fee for participation is far higher).

Title: Why do programming language (open) standards cost money?

Body:
Isn't it counter-productive to ask for 384 Swiss franks for C11 or 352 Swiss franks for C++11, if the aim is to make the standards widely adopted?

Please note, I'm not ranting at all, and I'm not against paying; I would like to understand the rationale behind setting the prices as such, especially knowing that ISO is network of national standard institutes (i.e. funded by governments). And I also doubt that these prices would generate enough income to fund an organization like that, so there must be another reason.


答:
Many of the older standards organisations do still charge for their standards, but IMHO it acts as a barrier to wider adoption of the standards.

Many standards organisations already manage to provide their standards free. IMHO organisations like ISO and ANSI seem quite outdated by still charging.

Here is an arbitrary personal selection of important standards that can apparently be published free.

W3C. Here's the XML standard and the HTTP standard to download for free.

Unicode standard published free online.

ECMA. Here's the C# standard as a free download. Or, if you need a tax loss, it's 238 Swiss Francs from ISO.

Open Geospatial Consortium standards which are important in GIS and web maps.


答:
This is going to be a large and very involved project.  I've been responsible for migrating Access databases to .NET many times, but never on this scale.  I agree that a gradual approach will probably be the most realistic.  Trying to take on everything in one shot is an easy way to fail.

As in other answers, the first and most important step will be to move everything to SQL Server.  While doing this, document the database if this hasn't already been done, and identify areas for refactoring if they exist.  Access databases that grow to meet evolving needs often have data models that can be improved upon when looking at the big picture.

Next, identify modules of the application that are "self contained".  Because this is a do-everything database, there will probably be modules of it that are nearly completely disjoint from each other.  After having these disjoint pieces, identify one of the smaller modules that has the most to gain from being updated, and take it on first.

While migrating to .NET, don't just do a simple 1 to 1 copy of the application.  Gather input from users to identify pain points with the current application.  You want your first migration unit to be a huge success to gain the complete buy in from everyone else.

After you have the first unit done, look at what happened in terms of challenges, difficulties, etc, and use this moving forward.

One thing that I would strongly discourage would be to implement partially working modules (ex: "we migrated the CRM, but features X,Y,Z are not in the new system yet").  This will cause users to quickly become frustrated from having an incomplete system when the old one to them was "perfectly fine".  This kind of development may work fine for other domains, but not in businesses where users see "nothing wrong" with the old Access monolith and don't understand the migration needs.


问:
Template for writing requirements/specs for a WCF service interface
I need to write requirements/specs for a WCF service interface between our system and a third-party BizTalk server. I'm not quite sure how to do this, so I'm looking for a template. I guess I should at the very least define the interface itself, authentication policy and error handling. Any resources regarding documenting WCF/SOA requirements would be appreciated.</p>

答:
I couldn't find any readily available templates, but I would suggest looking at Interface Control Documents to get some ideas. This type of document is designed to describe the boundary between two or more systems, and seems to be exactly what you are looking for. There are many variations, ranging from a formal specification in textual form to combinations of sequence, deployment, and data flow diagrams.

You can also take a look at a more generic software requirements specification template. The format of the document isn't the important part, but what information is captured is. This includes use cases and the functional and non-functional requirements.

Regardless of the method(s) you choose to capture the requirements, your process methodology will probably dictate what output would be most useful to the development team. In a plan-driven methodology, the expected output would probably be textual documents with appropriate diagrams inserted. In more agile methodologies, the functional requirements of the system would probably be captured as use cases and user stories and any associated diagrams would contain just enough information to increase the understanding of the system.

To the best of my knowledge, there isn't anything unique to the particular technologies you mentioned - requirements and specifications exist at a level above the technologies chosen to meet those requirements.


问:
Strategies for counting child objects
What is an efficient, OOP way to count child records of an object?

In my current project, a District may contain zero or more School records. The Districts object acts as a collection of District, and can perform a single query to get the data behind several District in one go, rather than each District (Active Record) querying for its own data. District->schools() provides access to child schools.

On the page in question, I want to list all the districts and a count of their child schools. This is getting very sluggish as the number of districts grows, as each district must again query the schools table. Additionally, the database driver we're using does not provide a row count for the record set, so that would be another query. Some things I've considered:

An optional object available through a service locator which can provide counts.

Storing the child count with the parent record.

So, my current method of counting child records is pretty heavy. What are some ways I could lighten this load?

答:
An optional object available through a service locator which can
  provide counts.

Yes that works, but be sure to it in one query.. (To keep it in OO, Add a method in the appropriate Place, that runs the query and returns a collection)

```<code>Select DistrictID, D.name,count(s.SchoolID) AS CountOfSchools
    from District s
    left join School s on s.DistrictID=d.DistrictID
group by DistrictID, D.name
</code>```

*This assumes each school can only be in One district.

Storing the child count with the parent record.

This Works Too! But Don't De-normalize your data, Create view (Like the above query) that your object has access to for calculated data. Note that this view is a simple one to one relationship your district table.

Title: Strategies for counting child objects

Body:
An optional object available through a service locator which can
  provide counts.

Yes that works, but be sure to it in one query.. (To keep it in OO, Add a method in the appropriate Place, that runs the query and returns a collection)

Select DistrictID, D.name,count(s.SchoolID) AS CountOfSchools
    from District s
    left join School s on s.DistrictID=d.DistrictID
group by DistrictID, D.name

*This assumes each school can only be in One district.

Storing the child count with the parent record.

This Works Too! But Don't De-normalize your data, Create view (Like the above query) that your object has access to for calculated data. Note that this view is a simple one to one relationship your district table.