答:
If anybody is using reflection to call your private methods, it's a sign that someone is doing something wrong. Either he's using the code in ways it wasn't designed for, or you're hiding too much of the internal workings and dumbing down the API.

But it sounds like you're not even at that stage yet, and are just trying to be pre-emptive. So my opinion is: don't worry about it. A private method should be considered off-limits; if someone deliberately violates those limits, then it's their problem if things blow up.

Title: Do I need to deal with the situation where private methods are called through reflection?

Body:
When creating a library, must I ensure that the private methods must work as expected when called not by other methods of the same class, but by another library through reflection?

For example, if a private method private DoSomething(int number) expects that:

number is a positive non-zero integer, and:

a private variable string abc is not null and not an empty string,

and completely, ugly fails if those two conditions are not matched, must I handle those failures even if I know that all methods in the class will always¹ assign a non-empty value to abc before calling DoSomething, and pass a positive non-zero integer to this method?

In other words, is the code which is not protected against unsafe calls through reflection can be considered as low quality code, or it belongs to the caller who uses reflection to ensure that the call does not break anything?

Note: my question covers only a standard set of libraries. This does not cover code which must be highly secure (i.e. when somebody may be interested by using reflection in order to make it behave unexpectedly or crash).

¹ Because the class is correctly documented, because there are enough unit tests to be sure that any other developer will not break this method, etc.


问:
What is best practice on ordering parameters in a function?
Sometimes (rarely), it seems that creating a function that takes a decent amount of parameters is the best route.  However, when I do, I feel like I'm often choosing the ordering of the parameters at random.  I usually go by "order of importance", with the most important parameter first.

Is there a better way to do this?  Is there a "best practice" way of ordering parameters that enhances clarity?

答:
Oftentimes a complex object as a parameter is better -- a poor man's version of named parameters that works on most platforms. And opens the door to parameters with behavior to boot.

For an example of most things you shouldn't do you might want to try reading PHP's standard library documentation.

ContentLicense: CC BY-SA 3.0


问:
Company wants thoughts about their site during interview
I have an initial phone interview coming up with a company for a Senior Web Developer position and in the email they asked to prepare by signing up on their site because they'd like to hear my thoughts about it and suggestions for improvement.

I've heard stories before of companies that do this.  They interview 10 people and then if everyone gives advice, then they've got a lot of free consultation.

I believe this is the first time I've ever been asked to do something like this so I wanted to hear other people's thoughts of whether it is free consulting or if I'm just being paranoid.

答:
I remember my previous company asked me the same question on the interview. What I came to know about this is that : - Normally product companies asks you these kind of questions, since its their own product and obviously they require new ideas to implement on it, they want their products to be great. And its even obvious that they will look for people who can even give them nice ideas on their products rather than just doing the job which you were asked to. They expect your suggestions, improvements etc.. So if you can give them awesome ideas, and if you have already met with their technical requirement then they will try to buy you at any cost.

My Experience in this:

When I was asked to give suggestions and improvements: I just went through their websites one by one, their main product was local city portals. I just clicked each link and whatever came on my mind, I just noted down . And when they asked I had a huge list to tell them. Few of them were these..

The site had a lot of different app like realestate, education, QA, gallery, article etc.. But a global search was missing.

Their education part was so week that I didn't get what I expected.

I suggested for including a "Movies" section. Since the site mainly focus on local city users, Placing list of movies playing in their city, their showtimes, trailers etc.. can attract more users

Including comments and user reviews for all the sections. Good for SEO

I had a huge list and even I got the job.

I just gave you my experience on this, Hoping that you will get some points from this.


问:
Implementing a machine learning algorithm to detect the region of an address
I have 10,000 addresses from a city, which all have a region field in the database.
When a new address is entered, then I want my software to automatically detect the region of the address .

I think it should be implemented with some sort of machine learning algorithm. How can I do this?

And with every newly inserted address, the machine should learn to detect the region of the new address.
Is there any library for machine-Learning algorithms (like aforge.net for neural networks)?

答:
I think there're clear rules on how cities are partitioned into quarters or regions. You should ask your local administration on where they draw the borders. Then you could, for example, retrieve the location data of the address (latitude and longitude might work) and simply check in which region's boundaries this address is in. There's no need for a learning algorithm for this problem.

However, if you can't acquire the boundary data for the partitions then I'd try to find the nearest known region, probably by distance. Again, I see no sense in an evolving algorithm or some sort of AI here. Either you can determine the region deterministically by known boundaries or you can try to find the nearest known region. AI is imho an overkill for such a task. You'd have to constantly recalculate initially guessed region-boundaries and evaluate them and then update existing addresses of which the region is known to be uncertain. Also, you'd have to feed the system constantly with addresses of which the region is known to verify uncertain regions.

But as regions are very unlikely to change their borders, I'd just try to obtain the boundaries, like stated above, from the local administration.


问:
Are there problems with using Reflection?
I don't know why, but I always feel like I am "cheating" when I use reflection - maybe it is because of the performance hit I know I am taking.

Part of me says, if it is part of the language you are using and it can accomplish what you are trying to do, then why not use it.  The other part of me says, there has to be a way I can do this without using reflection.  I guess maybe it depends on the situation.

What are the potential issues I need to look out for when using reflection and how concerned should I be about them?  How much effort is it worth spending to try to find a more conventional solution?

答: One problem we have had with Reflection is when we added Obfuscation to the mix. All classes get new names and suddenly loading a class or function by its name stops working.


问:
Is it practical to use Twitter for service logs?
Recently my boss suggested that we post logs of our service that is hosted on Windows Azure into twitter. His idea is that it's conveniently readable and if Azure cloud fails logs persist. He also said, lots of people do this, I Googled and couldn't find any data about this.

Currenly my concerns are the following. First, perhaps twitter is not very convenient for logging something that can happen very frequently (for example, when our service role starts each instance writes tens of records over several minutes). Second, even if twitter EULA allows such use at this moment it might be changed in future to cut off tweets that occur too often to be human-originated.

Is it practical to post service logs on twitter? What to consider if we implement this?

答:
Hmmm, I think this is for what Loggly was created.

Loggly is a cloud logging system based on Apache Solr technology. As they say, it can handle millions of events per second. Seeing your needs, this solution can fit. In addition, they exposes a search API using a sort of custom query language.


问:
Why do so many libraries have no/poor documentation?
In a similar vein as the How can open source projects be successful without documentation about their design or architecture? question, I'm curious: Why are so many libraries so lacking in end user documentation?

My view is this:

Most everyone agrees that reading source code is more difficult than writing source code.

Without documentation, one must read the library's source code in order to use that library.

Therefore, using the undocumented library is more work than just recreating the library from scratch.

As a result, if you want to have people use your library, you'd damn well better make sure it's documented.

I know lots of developers don't like writing docs, and I'll agree it can be tedious work. But it's essential work. I'd even say it's more important that a library have good documentation than have the best programmer's interface in the world. (People use shitty libraries all the time; few use undocumented libraries)

Oh, note that when I say documentation, I mean real documentation. Not Sandcastle/Javadoc/Doxygen boilerplate.

答:
You pointed out the answer yourself:

I know lots of developers don't like writing docs, and I'll agree it can be tedious work.

As programmers, we enjoy writing code, but very few of us also enjoy writing documentation.

While any good coder knows the value of good documentation, it also takes a fair amount of time to do it properly. As it's not enjoyable and takes a long time, it gets put in the "to do later" pile so it never gets done to a satisfactory level.

As a side note, it's also very hard for a programmer to  write documentation on their own product. As they know the system so well, certain things are obvious to them. These parts often never get mentioned despite not being obvious to the consumer.


答:
I think you've mostly answered your own question: because in most cases, developers just won't bother. The problem is especially prevalent in volunteer projects.

I do think there's another major problem though: in a lot of cases, developers haven't really developed an overall model of how their library works (or just have difficulty articulating that model clearly). Unfortunately, articulating that model and how the pieces of the software fit together is often the most important part of the documentation.

In a typical case, what's written has a very high-level overview ("This is a library for doing cool stuff!") and then a very low-level description (type and description of each parameter to be passed to each function). Unfortunately, there's rarely an intermediate level about the general theory of how things are supposed to work, how the pieces fit together, etc. Much of this goes back to the fact that developers often haven't attempted to form, rationalize, or understand their code at that particular level of detail. At least in some cases I've seen, developers who were asked to write documentation at that level found it quite problematic -- to the point that many wanted to rewrite the code so it would be more organized and easier to explain at that level of detail.

Writing well at that level of abstraction is often difficult -- and if the developer hasn't really thought about it at that level of abstraction, they'll often find the code somewhat embarrassing, and might want to rewrite it before they're happy about releasing it at all.

Title: Why do so many libraries have no/poor documentation?

Body:
In a similar vein as the How can open source projects be successful without documentation about their design or architecture? question, I'm curious: Why are so many libraries so lacking in end user documentation?

My view is this:

Most everyone agrees that reading source code is more difficult than writing source code.

Without documentation, one must read the library's source code in order to use that library.

Therefore, using the undocumented library is more work than just recreating the library from scratch.

As a result, if you want to have people use your library, you'd damn well better make sure it's documented.

I know lots of developers don't like writing docs, and I'll agree it can be tedious work. But it's essential work. I'd even say it's more important that a library have good documentation than have the best programmer's interface in the world. (People use shitty libraries all the time; few use undocumented libraries)

Oh, note that when I say documentation, I mean real documentation. Not Sandcastle/Javadoc/Doxygen boilerplate.


问:
What to do with a not well organized application?
I'm a newly graduate programmer and just got hired before my graduation. In the office, I used to create and revise modules of some applications developed by other programmers in our company. The problems I encountered with their applications are:

Unnormalized database at it's best, they've broken all the rules of database normalization, Codd must be angry.

50% of the content of the database is literally NULL (they should have default value I swear).

One stored procedure is used in all database transactions, full of "if-else" statements.

They are reinventing the application settings in .NET WinForms, they create their own file which contains everything they want. I think they are very fan of VB6 or maybe they don't study really, they're guessing how to achieve something.

No error handling! Clients sometimes report "Exceptions" which they shouldn't be seeing.

Web files and Windows Forms are not organized or grouped according to their use.

Naming convention, there are Camel case, pure lower case, with and without underscores and abbreviations.

Bad programming practices like database transaction in each iteration of a loop.

They developed website with SQL injection in mind, they welcome them.

HTML elements were not used according to their sematics.

CSS are not optimized for different browsers.

They include several versions of jQuery in one HTML!

.
.
.

N. Many more!

The worst thing is, I felt being blamed for it's fragility. I mean, when I add code, there are times that it ends up with error, sometimes because they did not create constraints or they allowed duplicate data. The system is so fragile and dependent to one another, it's like walking in a field with landmines! (THIS HAPPENS SOMETIMES, THIS IS NOT THE REAL ISSUE)

What should I do?

答: I would try explain to two of my seniors in a meeting (one programmer, one not) that it's badly written and that it would probably save your employer money to let you rewrite it now and reduce maintenance work in the future, than attempt to keep maintaining it as it stands.</p>


答: Suggest code reviews to your lead programmer. This will provide a non confrontational environment you can criticize the code. Also it will help you pick up techniques of building stable code in a fragile environment.</p>

Title: What to do with a not well organized application?

Body:
I'm a newly graduate programmer and just got hired before my graduation. In the office, I used to create and revise modules of some applications developed by other programmers in our company. The problems I encountered with their applications are:

Unnormalized database at it's best, they've broken all the rules of database normalization, Codd must be angry.

50% of the content of the database is literally NULL (they should have default value I swear).

One stored procedure is used in all database transactions, full of "if-else" statements.

They are reinventing the application settings in .NET WinForms, they create their own file which contains everything they want. I think they are very fan of VB6 or maybe they don't study really, they're guessing how to achieve something.

No error handling! Clients sometimes report "Exceptions" which they shouldn't be seeing.

Web files and Windows Forms are not organized or grouped according to their use.

Naming convention, there are Camel case, pure lower case, with and without underscores and abbreviations.

Bad programming practices like database transaction in each iteration of a loop.

They developed website with SQL injection in mind, they welcome them.

HTML elements were not used according to their sematics.

CSS are not optimized for different browsers.

They include several versions of jQuery in one HTML!

.
.
.

N. Many more!

The worst thing is, I felt being blamed for it's fragility. I mean, when I add code, there are times that it ends up with error, sometimes because they did not create constraints or they allowed duplicate data. The system is so fragile and dependent to one another, it's like walking in a field with landmines! (THIS HAPPENS SOMETIMES, THIS IS NOT THE REAL ISSUE)

What should I do?


答:
I think the best thing that you can do is to set with your team members and discuss the issues you listed with them.

It shouldn't be about blaming each other, neither it should be pulling hair sessions. What is really matter is the project itself. You should all keep this in mind.

Talk with them about the decisions they made, maybe there is a reason (who knows?)

Also keep in mind that you are newly graduated programmer, so you shouldn't generate the impression that you consider yourself better than your team members. Because many new fresh graduated persons fall in this trap.

Use (innocent or not so innocent) questions to expose the fragility you are talking about.


答: Quit this job. I've worked on a similar project (except database was OK, but the whole application contained like 3 real classes, all CRUD code was like Issue.Create (50 parameters here) and IDictionary<string,object> Issue.Get(int id)), put some tests in, wrote new functionality in clean fashion but decided I want to do something else with half of my life.


答: If you're a newly examined programmer - don't suggest The Grand Rewrite. Improve it little by little, step by step. You're begging for trouble rewriting the whole application. I find that the biggest hurdle to choosing incremental improvement is in one's head - "how can we possibly clean up this mess?" But more often than not, it's easier than you think, just take baby steps.</p>


答:
I hate asking this question because I seem to have been asking it a lot lately.

Is there a local coding standard in place? If not, would you consider drafting one, if nothing else to deal with some of the more stupid problems like a) naming conventions b) acceptable error handling and non-standard use of languages?

Do you have any sort of a bug tracking system so that when you make some change and it highlights some pre-existing bug that you can track all these things?

If you want to stay there, you cannot hope to fix all of the problems at the same time. You need to look at two options 1) prevent broken stuff in the future - imo this may be higher priority and 2) start fixing previously broken stuff. I don't know how big your code base is but my money is on this: you will not get it all re-written in the short term and if your next year consists of rewriting broken stuff you're going to want to leave anyway.

I'd be leaning towards moving if there are any other viable alternative options. If not, give yourself a time frame to see how things shape up and then make a decision about whether to stay or not.


问:
Into which artifact does one package intermediate classes?
We have modularized our API into some independent components.
Independent meaning these can be built via Maven and used as dependencies for other projects such as webapps.

Now, to use this API, there needs to be an intermediate processing class which does a translation of the client data model into the callee (component) data model.

The question is does this handler/processor class belong and need to be packaged along with the client application JAR/WAR or is it part of the component JAR.

What is the convention?

答: I've typically used a separate module for this. That way it's also versioned alongside the client and the server components.</p>


答:
You basically have two options:

Get a new job

Make your current work environment better.

option 1. is self explanatory, but for option 2, that means being a good programmer despite everything else going on around you.  Religiously stick to good practices and conventions.  Try to make these conventions fit in with what already exists as much as possible (especially on things where it doesn't matter too much, like naming conventions - there is no point in doing anything wildly different to what has been done before else you'll end up in this situation: xkcd)

One thing that every one hates (regardless of actual truth) is being told that what they've done is useless;  especially by a young, inexperienced junior (I graduated 3 years ago, believe me, they really don't like it).  All you can do is lead by example.  If you are unlucky and no one follows you, then at least some areas of the code that you work on will start to improve, if you are lucky, some may even continue what you've started...
Joel Spolsky has a good article on this sort of thing, there are loads of other great articles on his website too.

Remember as well:  no job is perfect,  no one writes perfect code and sometimes it is not immediately obvious why a particular piece of code was written like it was.

Do your work well and listen to what other programmers (especially those you work with) have to say.  If you aren't sure about their advice, then ask questions, just keep them dressed down and never use them to imply you don't think the current system is very good. Keep questions simple and expect a rational answer to them, that way you won't get people's defenses up and either you will get the answer you needed or you will be congratulated for spotting a flaw / problem that no one else though of.


答:
Find out what led to this application and attack the reason

On a purely technical level, you already know what to do: normalize the database, add constraints/defaults, refactor the stored procedure, etc, etc.

But, in my experience, this is only circumstantial. The real problem is the Environment that produces such a mess.

And there may be different reasons.

One could be that the team honestly does not know better (I mean, for each of us there was a time when we didn't). In this case, you could carefully try to educate them. The objective here would be to sensitivise them to their wrongdoings, so that they too see the application and not you as the problem. The danger here is to come across as 'the nagger', so be careful to criticize the code, not the person.

Maybe they feel forced to code quick and dirty. In this case, try to establish that excellency pays off. This is in my experience done best by example, and by standing ground where quality is about to be sacrificed.

the hardest, and in my experience most common scenario is they think it's 'pragmatic' and best practice, due to groupthink and little exposure to quality. There are many proposed solutions to such a scenario (often quoted 'how to get things done as a grunt'), but in my experience, that does not work: when your new code causes a weird side effect, you get blamed for not having memorized all their weird dependencies ("you cannot call the date function inside the customers module, you need more discipline"), and not the... "programmer" who thinks 'loose coupling' is for hippies.

To quote someone: "Things are the way they are because they got that way ... one logical step at a time". Your problem is not the denormalized database, your real Problem is the Team's justification for it.


答: I think sometimes it's because the developer is so wrapped up in the code that it's "obvious" to him/her how it works and they can't see why it wouldn't be obvious to anyone else.  Similarly, loads of product web sites say how wonderful their product is, but don't actually tell you what it does!</p>


问:
Does Scrum turn active developers into passive developers?
I'm a web developer working in a team of three developers and one designer. It's now about five months that we've implemented the agile scrum software development methodology. But I have a weird feeling I just wanted to share in this site.

One important factor in human life is decision-making process. However, there is a big difference in decisions you make. Some decisions are just the outcome of an internal or external force, while other decisions are completely based on your free will, and some decisions are simply something in between. The more freedom you have in making decisions, the more self-driven your work would become. This seems to be a rule. Because we tend to shape our lives ourselves.

There is a big difference between you deciding what to do, or being told what to do.

Before scrum, I felt like having more freedom in making the decisions which were related to development, analysis, prioritizing implementation, etc. I had more feeling like I'm deciding what I'm doing.

However, due to the scrum methodology, now many decisions simply come from the product owner. He prioritizes PBIs, he analyzes how the software should work, even sometimes how the UI and functionality should be implemented. I know that this is part of the scrum methodology, and I also know that this may result in better sales of product in future. However, I now feel like I'm always getting told to do something, instead of deciding to do something. This syndrome now has made me more passive towards the work.

I tend to search less to find a better solution, approach, or technique

I don't wake up in the morning expecting to get to an enjoyable work. Rather, I feel like being forced to work in order to live

I have more hunger to work on my own hobby projects after work

I won't push the team anymore to get to the higher technological levels

I spend more time now on dinner, or tea-times and have less enthusiasm to get back to work

I'm now willing more for the work to finish sooner, so that I can get home

The big problem is, I see and diagnose this behavior in my colleagues too. Is it the outcome of scrum? Does scrum really makes the development team feel like they have no part in forming the overall software, thus making the passive to the project?
How can I overcome this feeling?

答:
I'm not really in tune with the whole scrum thing as have been more waterfall for a while. </p>

<p>But to be honest, this sounds more like a management personnel issue than a project management technique issue. As in it's more people based than technique based. </p>

Body:
I'm not really in tune with the whole scrum thing as have been more waterfall for a while.

But to be honest, this sounds more like a management personnel issue than a project management technique issue. As in it's more people based than technique based.


问:
Will there be any official LINQ like lambda based library for C++?
Given C++ gained lambdas with C++11, will there be any LINQ like higher order function library officially supported later? Or is there already such a library used in production quality code?

Obviously I'm not expecting the SQL-like expression tree based LINQ query syntax in C++. I am talking about the lambda based one. So, no new language feature in needed in C++'11, just a library will do.

答:
Notes : For C++2011 there is not such functionality.
Fortunately, the next C++ should include a filesystem library (see boost::filesystem) so you can guess that such a database library will not be standardized soon.

There are several (and some recent) discussions on the boost mailing list about such library. Several people are pointing to potential boost-like libraries like SOCI and CPPDB.

Also, I don't see how lambdas can help for such a functionality. Lambdas are still code, not EDSL constructs.


答:
I think, that simply you guys are used to having more ownership - and everyone I think prefers that, its human nature.

Unfortunately I think a lot of software is less than it could be, because often parts are written for the dev and not the client. Your new approach should reduce that, but at the expense of your ownership feeling.

I've no idea how to suggest you make things better or more fun but it's a great question and a very good insight.

Title: Does Scrum turn active developers into passive developers?

Body:
I'm a web developer working in a team of three developers and one designer. It's now about five months that we've implemented the agile scrum software development methodology. But I have a weird feeling I just wanted to share in this site.

One important factor in human life is decision-making process. However, there is a big difference in decisions you make. Some decisions are just the outcome of an internal or external force, while other decisions are completely based on your free will, and some decisions are simply something in between. The more freedom you have in making decisions, the more self-driven your work would become. This seems to be a rule. Because we tend to shape our lives ourselves.

There is a big difference between you deciding what to do, or being told what to do.

Before scrum, I felt like having more freedom in making the decisions which were related to development, analysis, prioritizing implementation, etc. I had more feeling like I'm deciding what I'm doing.

However, due to the scrum methodology, now many decisions simply come from the product owner. He prioritizes PBIs, he analyzes how the software should work, even sometimes how the UI and functionality should be implemented. I know that this is part of the scrum methodology, and I also know that this may result in better sales of product in future. However, I now feel like I'm always getting told to do something, instead of deciding to do something. This syndrome now has made me more passive towards the work.

I tend to search less to find a better solution, approach, or technique

I don't wake up in the morning expecting to get to an enjoyable work. Rather, I feel like being forced to work in order to live

I have more hunger to work on my own hobby projects after work

I won't push the team anymore to get to the higher technological levels

I spend more time now on dinner, or tea-times and have less enthusiasm to get back to work

I'm now willing more for the work to finish sooner, so that I can get home

The big problem is, I see and diagnose this behavior in my colleagues too. Is it the outcome of scrum? Does scrum really makes the development team feel like they have no part in forming the overall software, thus making the passive to the project?
How can I overcome this feeling?


问:
Is Functional Programming possible in Java?
I was browsing through the Amazon.com Bookstore and I came across the book "Functional Programming for Java Developers".

I know some very basic Functional Programming and have been programming in Java for 3 years.

I would like to know is Functional Programming even possible in Java?

答:
Yes, it is definitely possible, in the same way that it is possible in any turing-complete language / execution environment combination. You can even get it to perform quite well if you know what you are doing.

Not sure how sensible it is though. In particular, be aware that it's not particularly idiomatic (i.e. it will look very strange, you will have to do some unconventional things and confuse people who are used to regular Java)

You'll end up with some odd looking code, e.g. to define a new function:

```<code>Function twoStrings=new Function() {
  public Object apply(Object param1) {
    // do something to param1 and return a result
  }
}
</code>```

To do functional programming you typically need:

First class functions - easy to create in Java by defining an abstract class or interface that represents your "Function" and has an "apply" method which applies the function to one or more parameters.

Closures - create an instance of your function object above with the closed-over values stored in final fields. You can use an anonymous inner class for this.

A library of standard higher order functions - this is trickier, however you can still write your own to bootstrap a simple functional language in a few hours. If you want something fancier, you can check out other functional libraries people have built in Java.

So it's possible as an exercise and even an interesting hobby project. But you really want to do serious functional programming while maintaining the advantages of the JVM / accessing Java libraries then Clojure is by far your best option in my opinion.

p.s. since the core of Clojure is actually written in Java, it's actually a very interesting case example of how to do functional programming in Java while hiding the messy details behind a nice new modern language syntax. Clojure source code is on GitHub for those interested.

Body:
Yes, it is definitely possible, in the same way that it is possible in any turing-complete language / execution environment combination. You can even get it to perform quite well if you know what you are doing.

Not sure how sensible it is though. In particular, be aware that it's not particularly idiomatic (i.e. it will look very strange, you will have to do some unconventional things and confuse people who are used to regular Java)

You'll end up with some odd looking code, e.g. to define a new function:

Function twoStrings=new Function() {
  public Object apply(Object param1) {
    // do something to param1 and return a result
  }
}

To do functional programming you typically need:

First class functions - easy to create in Java by defining an abstract class or interface that represents your "Function" and has an "apply" method which applies the function to one or more parameters.

Closures - create an instance of your function object above with the closed-over values stored in final fields. You can use an anonymous inner class for this.

A library of standard higher order functions - this is trickier, however you can still write your own to bootstrap a simple functional language in a few hours. If you want something fancier, you can check out other functional libraries people have built in Java.

So it's possible as an exercise and even an interesting hobby project. But you really want to do serious functional programming while maintaining the advantages of the JVM / accessing Java libraries then Clojure is by far your best option in my opinion.

p.s. since the core of Clojure is actually written in Java, it's actually a very interesting case example of how to do functional programming in Java while hiding the messy details behind a nice new modern language syntax. Clojure source code is on GitHub for those interested.


答:
It sounds like your adventures into Agile have been corrupted by Scrum. I find that, of all the agile methodologies, Scrum is the least agile. Its more like miniature waterfalls and additional project management. This, of course, makes it the most liked by management who feel them are taking control back from those pesky developers, but of course you see the reality of the situation.

Agile is not about following a prescribed path, it is designed to make you more productive and motivated. People not processes says the manifesto (paraphrased), and that's lost in the system you're using.

So change it. Bring it up with the management and say that it is a retrograde step, that your productivity is less than it used to be and you're all unhappy with the way its working out. Show the Agile Manifesto (and its evil twin) and demonstrate that you've not only learned lessons from this experiment but  want to evolve the good bits from it into a better system (one that's like you used to have, which appears to work well for you).


答:
LINQ-to-objects is already supported in the Standard library and has been since it's inception. The syntax is just a bit different- it was never intended to emulate SQL and has way too many iterators in it. You can make it more reminiscent without too big a hassle.

Edit: When actually attempting to make it more reminiscent without too big a hassle, I determined that it actually could be a significant hassle. It is, however, still completely possible.

Title: Will there be any official LINQ like lambda based library for C++?

Body:
Given C++ gained lambdas with C++11, will there be any LINQ like higher order function library officially supported later? Or is there already such a library used in production quality code?

Obviously I'm not expecting the SQL-like expression tree based LINQ query syntax in C++. I am talking about the lambda based one. So, no new language feature in needed in C++'11, just a library will do.


答:
There's ODB which is interesting.

see the sample code from the ODB wikipedia entry that searches for all people called Doe younger than 30 (age and last are DB columns, directly mapped to a class, this is done by the ODB compiler to it always keeps automatically generated classes in sync with the DB schema, without having to modify a DB->code mapping definition file or assembly). I like it because of that, having had to maintain an Entity Framework assembly.

```<code>  transaction t(db.begin ());

  result r(db.query<person>(query::last == "Doe" && query::age < 30));

  for (result::iterator i (r.begin ()); i != r.end (); ++i)
  {
    cout << "Hello, " << i->first () << endl;
  }

  t.commit ();
</code>```

Body:
There's ODB which is interesting.

see the sample code from the ODB wikipedia entry that searches for all people called Doe younger than 30 (age and last are DB columns, directly mapped to a class, this is done by the ODB compiler to it always keeps automatically generated classes in sync with the DB schema, without having to modify a DB->code mapping definition file or assembly). I like it because of that, having had to maintain an Entity Framework assembly.

  transaction t(db.begin ());

  result r(db.query<person>(query::last == "Doe" && query::age < 30));

  for (result::iterator i (r.begin ()); i != r.end (); ++i)
  {
    cout << "Hello, " << i->first () << endl;
  }

  t.commit ();


答:
The answer is a resounding "yes, of course", yet in my opinion one of the most important features in many functional languages is the excellent type system. You'll never be able to manage this in Java yourself.

If you want to write functional programs and yet stay with the JVM I can recommend among the usual suspects Scala and Clojure to look at Frege. Frege has a syntax and type system that is very close to Haskell, but programs are translated directly to java code and can interact with other java code.

Title: Is Functional Programming possible in Java?

Body:
I was browsing through the Amazon.com Bookstore and I came across the book "Functional Programming for Java Developers".

I know some very basic Functional Programming and have been programming in Java for 3 years.

I would like to know is Functional Programming even possible in Java?


答:
I had the same experience with Scrum and like to call it the "tyranny of the story".

From my experience developers more on the creative/design/frontend side seem to suffer more from it than people involved in backend work.

The only way out I found so far was to either ditch Scrum – often not possible and/or appropriate because after all it has it's advantages – or to introduce something like Google's 20% time to give developers a creative outlet apart from the "you're free to choose how to implement the Login Page", because in reality you are not as your implementation is constrained by the existing code and system architecture – that is unless one considers the freedom to choose between 'a for and a while loop' a freedom.


答:
There is a big difference between you deciding what to do, or being told what to do.

In my experience, there's just a rather long way from being told what to do to deciding what to do.

At the end of this way it usually turns out that we were instructed not because them like power and not because them have nothing better to do. Quite the opposite, at the end of this way - when they gain sufficient confidence in our team - they seem to be relieved and happily pass us as much control as we can handle (and if their trust is really firm, they even try to pass more than that)

Oh and in my experience this has basically nothing to do with Scrum/agile. Happened with scrum, iterative, waterfall, whatever. Seems the matter of trust is er process agnostic


问:
Will my communication skills be wasted in a software engineering career?
I've been in the financial engineering arena (after BA Math and BA Computer Science) for about 5 years (20% analysis/programming, 80% communicating) and take pride in my ability to communicate with people and discuss technical problems (i.e. interacting with a team).  I love this part of my job.  Going to the white board to draw abstract ideas and brainstorm.

However, for many reasons, I want to transition my career into a technology company (software engineering) but I'm deeply afraid that I will fall into a stereotypical programming job where programmers code with big headphones on.  I certainly know this is only a stereotype but I've witnessed similar environments before (at startups) and it scares me to think that I would be migrating to a career of isolation.

I love coding and thinking algorithmically, but I don't want to give up interacting with people. I understand that having communication skills is only a positive, but am I setting myself up for career-happiness failure by transitioning into software engineering.  I'd love to hear any clarifications and/or advice.

答:
It depends on where you go. I know a quant trading company where you would spend plenty of time on the whiteboard, brainstorming with PhDs. I know a prestigious consulting firm where you would likewise do a lot of communicating, but with people that didn't have a tech background... I know of a big non-software Fortune 100 firm where you'd likewise be doing a lot of communicating, but it would mainly be playing politics.

OTOH, a lot of startups and software product companies need people for heads-down coding. Sure, you communicate some, but getting up to deliver a presentation that sells your firm is a lot different than just talking to other coders...

The one area where communication really comes into play is sales engineering / technical consulting / etc... That's where, if you're truly an excellent communicator (and not just a SW engineer that isn't socially awkward), you'll get paid nice money. There's some selling involved there too.


问:
How to handle storing the login data for various projects and web servers?
Hello and I'm apologizing in advance if this question doesn't fit programmers section of stackexchange.

I'll try to clarify what the problem is by telling a story where the problem originates from.
I'm working in a small company (8 people) where we have developers, sys admins and staff that handles day to day calls.

The problem is the logins. There are various logins, for example web server root login. Then there's MySQL login, login for apps that we develop and to make the thing even more complex - logins differ from local development and testing versions to the ones that are actually deployed which makes the whole thing even more messier.
What's happening is that no one knows all of the logins, and they're either written down somewhere deep on cryptically named files or certain people know them by heart. If someone who knows the login for the thing we need to work with is away (say holiday), the process of retrieving the login becomes a huge mess.

Now, we are aware how terrible that is and we're looking into improving our login / project management. The other problem is that not everyone should know all the logins.

My question is: how do you (or how would you) handle storing logins such as web server root information, web app admin login etc. in such a way that it's available to everyone within the company, but with restricted access (say, a secretary cannot obtain root details, no offence to secretaries)?

P.S. I just spent 3 hours obtaining the login details to change a simple spelling mistake on a project which took exactly 1 second after I had the info. Seeing I can't afford losing any more nerves or time over such seemingly trivial things, I'm begging experienced and smart guys for help. Thanks in advance :)

答:
Assuming you have some sort of local network domain, setup users and groups for each person in the company for that domain. This will be the main-login for every person. On some shared network drive, create folders for each group and restrict access to them for groups and individuals. In these folders, you can store the password-lists and make them accessible only for people who are in a certain group or should've access as an individual.

Alternatively, if your source control system supports it, have the password documents under source control and apply the same scheme of users and groups to repository locations. Then anyone belonging to a certain group can access all the passwords he/she needs.

You can also try to employ technologies like LDAP or buy a software solution for your company, there're lots on the market. A quick google search turned up with this for example.


答:
However, I now feel like I'm always getting told to do something, instead of deciding to do something.

This is a serious indicator that something has gone off the rails. An agile project should not feel like this. That "people over process" rhetoric should include "we don't force our people to do things that suck." Here are some ideas:

Are you doing "scrum but"? That is, part scrum, part some other thing. (ie: "We're doing scrum, but all our stories have to come from our PMO, not a product owner.") Lots of crazy crap is called Scrum these days.

Are you, personally, not involved in the process where you should be? I've known a number of people to be upset at the contents of stories, and it turns out that they only get involved once the story is in the sprint backlog. Talk with the product owner early on in the development of the story, and get your feedback in. (As the PO, they have the final say, but that doesn't mean they have to do it alone.)

In Scrum, the team is supposed to own the process, and it's expected that the process will change over time to suit the team's needs. Bring up your concerns at the retrospective. If you can come up with a process tweak to suggest, that tends to make it easier to sell for some teams.


答: You might want to look into a group password safe product, we use something called SecretServer for just this sort of thing. They also have an online version if you don't want to host it yourself.</p>

Title: How to handle storing the login data for various projects and web servers?

Body:
Hello and I'm apologizing in advance if this question doesn't fit programmers section of stackexchange.

I'll try to clarify what the problem is by telling a story where the problem originates from.
I'm working in a small company (8 people) where we have developers, sys admins and staff that handles day to day calls.

The problem is the logins. There are various logins, for example web server root login. Then there's MySQL login, login for apps that we develop and to make the thing even more complex - logins differ from local development and testing versions to the ones that are actually deployed which makes the whole thing even more messier.
What's happening is that no one knows all of the logins, and they're either written down somewhere deep on cryptically named files or certain people know them by heart. If someone who knows the login for the thing we need to work with is away (say holiday), the process of retrieving the login becomes a huge mess.

Now, we are aware how terrible that is and we're looking into improving our login / project management. The other problem is that not everyone should know all the logins.

My question is: how do you (or how would you) handle storing logins such as web server root information, web app admin login etc. in such a way that it's available to everyone within the company, but with restricted access (say, a secretary cannot obtain root details, no offence to secretaries)?

P.S. I just spent 3 hours obtaining the login details to change a simple spelling mistake on a project which took exactly 1 second after I had the info. Seeing I can't afford losing any more nerves or time over such seemingly trivial things, I'm begging experienced and smart guys for help. Thanks in advance :)


问:
Do I need to deal with the situation where private methods are called through reflection?
When creating a library, must I ensure that the private methods must work as expected when called not by other methods of the same class, but by another library through reflection?

For example, if a private method private DoSomething(int number) expects that:

number is a positive non-zero integer, and:

a private variable string abc is not null and not an empty string,

and completely, ugly fails if those two conditions are not matched, must I handle those failures even if I know that all methods in the class will always¹ assign a non-empty value to abc before calling DoSomething, and pass a positive non-zero integer to this method?

In other words, is the code which is not protected against unsafe calls through reflection can be considered as low quality code, or it belongs to the caller who uses reflection to ensure that the call does not break anything?

Note: my question covers only a standard set of libraries. This does not cover code which must be highly secure (i.e. when somebody may be interested by using reflection in order to make it behave unexpectedly or crash).

¹ Because the class is correctly documented, because there are enough unit tests to be sure that any other developer will not break this method, etc.

答: Well, it's always a good idea to validate non-local variables before you use them, but other than that I wouldn't worry about it.  As the others said, you've established your intentions by making the method private in the first place; anyone calling it from outside your class has zero guarantees.  When working in Java, I don't even put javadoc comments on my private methods, because I don't want other developers to even know that they're there.


问:
Given C++ '11 Was Approved, Does This Change How A C++ Beginner Learns The Language?
I've wanted to learn C++ for awhile and took AP Computer Programming in High School (back when it was C++ and not Java). I enjoy C and just haven't found the time to learn C++ or I'll just fall back on C# where I'm much more productive.

My question is this: given that C++ '11 has been approved (although I know not fully implemented) does this change the way I should approach learning C++? I own C++: The Complete Reference By Herb Schildt which is from 1998. Does the newly approved standard make learning from such books less important than some of the newer tutorials/books that include things from the standard? Is there any benefit from learning from the older books?

答:
I don't know the specific book you mention. But in general you can say, that all the basics about C++ syntax, data types and OOP still hold true. The same should goe for the STL libraries that are mentioned in most beginners books.

Though a book as old as from 1998 may have missed a few updates and developments in C++ programming style, that accumulated in the community over the years. I would look for slightly more up to date resources. There are more than enough free online tutorials and documents that should provide you a good start. Some of them may even mention C++0x.

C++0x will for sure change a lot about how programmers see and use the language in future. But this would influence more complex projects where the new features start to make sense. For a beginner this shouldn't matter and you can concentrate on getting comfortable with the existing concepts, that's already enough to learn. Most beginner books don't go very deep into templates for example, so the new variadic templates are not what you need to know now.

Maybe have a look at a list of changes. At least a few concepts like range based for loops will most likely appear in new tutorials even for beginners. So it's worth to have a look.


答:
Addressing just the specific issues you mention: the serious ones are 5, 8 and 9. Users should not see exceptions, the bad practices with transactions will be hurting their performance (unless there's a good reason for them: check this before starting on tackling it) and SQL should never ever be injected. In fact, the fact that the application is vulnerable to injection attacks also indicates that it is slow: parameterized queries are quicker because the database can know for sure that they are values and doesn't have to check for complicated nested joins, etc. Safer, faster, better user experience: these are things that it should be possible to persuade your colleagues and managers of the real value of.

The other issues, while probably maddening (I emphasize that I don't know javascript so can't talk about the jQuery point), are things where you will probably have to just lead by example. Make sure that what you do is clean and easy to use and understand given the rest of the codebase: the goal should be that fellow developers can take up what you do without extensive training, and users can do it with (next to) no training at all. (Well, within the scope of what the user base is. Don't make it worse is what I mean!)


答:
Write an app that stores passwords.

Each user should be able to create a login/password combo, and share it with any other user. Nice-to-haves would be features like user groups so that you can share with other admins, etc.

If that sounds like too much work, buy a product.


答:
Almost every server product or product targeted toward businesses can use LDAP. I'd go so far as to say that it's irresponsible not to do it in this day and age.

Set up a directory server if you don't already have one, configure server products like mysql to use it, then update the authentication systems in whichever products you own the source for. One login for every app on the internal network.

Logins to vendor sites are another story but you don't really mention those. I wouldn't waste time maintaining an enterprise-wide password vault unless I absolutely had to; it's too easy to run into problems with sensitive information getting stored in the wrong place or low-level idiots forgetting the password to the password vault (or worse, writing it down on a sticky note and attaching it to their monitor). Even if the information doesn't seem all that valuable, I would only ever trust competent IT professionals with it. We use KeePass where I work but the database is in a restricted (Admin-only) location.

If everybody gets their own private password safe then that mitigates a lot of the harm (also a lot of the usefulness); shared password vaults violate non-repudiation and that is not a situation you want to be in when there's a major disaster and the auditors come a-sniffin'.


答:
Of course, with regard to anything technology related, being up to date with the latest material is always a smart move, however, the changes introduced in C++11 are designed not to rock the boat. If you're new to C++ (or programming in general), this isn't something I'd worry about.

Additionally, if you're a professional programmer, you can bet you'll be working on someone else's code in the future, so there is always value in understanding the way things work, even if it's a depreciated technique in practice.

Title: Given C++ '11 Was Approved, Does This Change How A C++ Beginner Learns The Language?

Body:
I've wanted to learn C++ for awhile and took AP Computer Programming in High School (back when it was C++ and not Java). I enjoy C and just haven't found the time to learn C++ or I'll just fall back on C# where I'm much more productive.

My question is this: given that C++ '11 has been approved (although I know not fully implemented) does this change the way I should approach learning C++? I own C++: The Complete Reference By Herb Schildt which is from 1998. Does the newly approved standard make learning from such books less important than some of the newer tutorials/books that include things from the standard? Is there any benefit from learning from the older books?


答:
I usually order them with required first, than by some combined measure of importancy and frequency of use according to a "feeling" (can be seen as ORDER BY required DESC, SOME_MAGIC_FEELING(importancy,frequency)) and not according to any specific practice.

However, as others have noted, I think the underlying problem that makes this an issue is using too many parameters (IMHO, anything >3 is too many) and that's the real problem that you should be addressing. There's an interesting post about that at rebecca murphey's blog.

I think that when you only have 1-3 arguments, the correct ordering is quite obvious and you just "feel" what's right.

Title: What is best practice on ordering parameters in a function?

Body:
Sometimes (rarely), it seems that creating a function that takes a decent amount of parameters is the best route.  However, when I do, I feel like I'm often choosing the ordering of the parameters at random.  I usually go by "order of importance", with the most important parameter first.

Is there a better way to do this?  Is there a "best practice" way of ordering parameters that enhances clarity?


答: I personally prefer the unhackable solution, write the passwords on a bit of paper and put those in a secure place when not in use.(such as the company safe).</p>


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

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

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

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

答: They're absolutely necessary since they have little experience.</p>


答:
Writing documentation is a skill. Like all skills it takes practice. The time and effort we spend writing code has a immediate pay off. We can see the new feature, the fixed bug, the improved speed. Writing documentation has a delayed payoff. It helps in the long run as new people need to work on the code or if we come back to work on the code months or years latter. It is only natural we focus on the short term.

In my opinion, the ability to write good documentation it one of the key traits that distinguishes great programmers from mediocre programmers.


答:
Pretty much, yes. The simple fact is that in C++98 and 03, many good practices were fundamentally unusable because of the poor quality of language support for e.g. functional programming. Now that lambdas exist and work, people tend to accept functional interfaces a lot better than they used to, and generic programming is even stronger than before.

In 1998, people were only just beginning to discover how to write high quality, safe, fast code using C++, and a lot of code was "C was Classes". In C++11, it's very different- idioms like copy and swap and the Rule of Three (now Five) are well known and defined, and a lot more resource managing types have become Standard, like shared_ptr and unique_ptr where the previous Standards simply left them as gaping holes.

You can view this question for an excellent list of reference material on C++.


答:
What is the difference with interfering with your ideas before checking in your code(review) or afterwards due to a bug, getting too clever/difficult to understand, or not following accepted standard practices? Is it your ego?

You can't disreguard the merits of code review or anything else just because it is being implemented poorly by a less qualified team member you don't respect. Code Review isn't some highly complex process that only a few super programmers are capable of grasping. I'm not sure there are many programmers or professional writers who are capable or have the time to self-edit.

Have you ever returned to a line of code a few months later and wondered what was I thinking? There would be a better chance of catching it with a code review. You just caught it and you're only slightly better than the programmer you were awhile ago - I hope.

Title: Are code reviews necessary for junior developers?

Body:
I've worked at two companies, who each had a different methodology when it came to code reviews:

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

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

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


答:
I'm guessing before Scrum, everybody just did what the wanted: yippee ki-yay mf'er. Your users are your benefactors and they drive the story and pay the bills. The product owner makes sure the story gets done. Some how, your group came to the conclusion that the Product Owner should be telling you how to program.

You want to write code or make neat little apps that you think are cool? "I want to do feature A first and not B, so I can maintain my freedom of choice." Find a different benefactor and not a new develoment methodology.

You're caught up in the Project Owner title or something. If you have a valid reason to disagree with the story, say something, make your arguement. You may not always win. It's their job to return to the users and let them know there is a valid issue with their request. Let's face it, if the story asks you to drop a database randomly throughout the day, without a backup, no loss of data or down time, you have a problem and a duty to set the story straight.


答:
Absolutely. These days three things that are usually in lesson 2 should move much, much later:

strings as arrays of char*, the strlen, strxxx methods, and so on

arrays in general and pointer arithmetic

delete what you new, delete[] what you new[], and even destructors

These things that are usually in lesson 99 should move much, much earlier

templates as things to use (write, not so much)

std::string

std::shared_ptr<>

std::vector<>, iterators, other collections

Evey raw pointer should immediately be given to a smart pointer wrapper (I would start with shared, and consider unique later since it requires explaining std::move and rvalue references). Doing this will make learning C++ feel a lot like learning Java or C#, where you learn the library at the same time as the language. It will take away a lot of the memory work, too, and leave people less worried about gotchas.

I would also work lambdas into the picture the first time we wanted to iterate through a collection and do something to each element.

Disclaimer: I am writing a C++ course for Pluralsight right now and using this approach. The last module is "understanding other people's code" and that is where I will put the confusing stuff like char* strings, manual memory management, pointer arithmetic, and so on.

Update: a few people have asked why the existence of C++0x inspires teaching things that could have been taught with C++03. I think it's a number of things:

truly smart pointers, that are collection friendly, take away the need for things like "an array of Employee pointers" that were causing us to always fall back on new/delete, pointer arithmetic etc

auto takes away the pain of iterator declarations

lambdas make foreaching something an ordinary person would do

even something as trivial as parsing >> correctly eliminates the gotcha that would be there when declaring some templates of templates

and so on

The way I see it, there are things we could have changed about the way we were teaching C++ some time ago, but some of us held back because we still needed the old-school way for a fallback or because teaching it just involved a lot of arcane knowledge.


答:
What you are describing is NOT SCRUM

Your product owner is over stepping his bounds if he is telling you  how to do your job technically, that isn't what SCRUM is about at all.

SCRUM is about freeing the developers to concentrate on development issues and empowering them take charge of determining how long things take and how to do them.

SCRUM is about collaboration, that is what Sprint planning meetings are for, to promote collaboration between all the stake holders; product owner, developers and testing.

Yes the product owner should prioritize features, what needs to be delivered first according to the customers needs, but the developers should be doing the engineering and design, not the product owner.

I don't agree that developers should be designing GUI's and workflows unless they are specifically tasked and trained to work with the customers and hash the functionality out with the customers directly. Programmer built GUI's done in a vacuum rarely meet customers needs.

SCRUM is about putting a light weight process that can be predictable and repeatable over the agile manifesto.

It makes me sad to hear stories that very good things are being perverted like this.


问:
What good reasons are there to capitalise SQL keywords?
There seem to be a lot of developers who write their SQL by capitalising the keywords:

```<code>SELECT column
FROM table
     INNER JOIN table
     ON condition
WHERE condition
GROUP BY clause
HAVING condition
</code>```

I'm wondering why people stick to this approach? Clearly, it's a long established convention - but I've never run into a RDBMS that requires capitalisation.

Personally, I find KEYWORDS THAT SHOUT to be calling attention to exactly the wrong part of the query, which is why I write the keywords in lowercase.

Still, enough people use this convention that I figure I might be missing something, hence this question.

答:
SQL is a clause-oriented language, much more than anything else I've experienced. You've got your SELECT clause, and your FROM clause, and your JOIN clause(s) and your WHERE clause. ORDER BY, GROUP BY, etc, etc.

Capitalizing those keywords helps you visually separate the separate clauses. This is especially handy when in one of those tricky debugging situations where you're outputting your SQL in an HTML comment, then copy-pasting into a console. Nasty, but we've all been there. It's good to have some help seeing where each piece of the statement starts.


问:
What are the Vital Things noticed in an Experienced Programmer Resume by a firm?
Hai Friends,
              Tell me or share with me , i am developer with one year experience, now i want to modify my old fresher resume to an experience resume, so i want to know what are the primary things must be in an experienced resume which is attracted by the firm.</p>

答:
One bit of advice I like (not mine, but I'm too lazy to look for sources) is to explain how each of your projects helped your customer/user/employer to improve or "generate value".

Example, you might have an item that reads:

Implemented Winforms application with .NET 2.0/Infragistics 2.3/SQL Server 2005/Crystal Reports 10.2/C#/Visual Studio 2005.

Try to rephrase to something like:

Designed, built and delivered a desktop reporting application that helped the Accounting Dept. to reduce invoice payment time from a manual task that used to take 3 days to an automated process based on realtime updated reports that now takes 10 minutes end to end. Implemented as a Windows application built on the Microsoft .NET platform.

Explain what your employer achieved with your work.

The technology tag soup can be left at the end of your resumé just to please recruiters that like to do text search for buzzwords.

ContentLicense: CC BY-SA 2.5


答: On the contrary, I've found that having a product owner make decisions about functionality allows me to devote more time to producing quality code.  Plus, if there are valid concerns, I can always question the product owners' decisions, and that usually leads to fruitful discussions.</p>


问:
Size of database a factor for Hibernate vs JDBC?
Do you know if the size of the database (number of tables used) is a factor when choosing between Hibernate and JDBC?

Why or why not?

In my particular case, I am evaluating Hibernate and JDBC for interacting with Oracle database for a small web app.

答:
The size in tables is by no means a concern when having to choose between the technologies. How could that possibly affect your choice? When you can map and generate your entities automatically, it doesn't even require you to write more boilerplate code when choosing an ORM.

It's rather a question about the tradeoff between programming close to the database and having an abstraction, although both can be mixed.

In general, sometimes it's better to program close to the database, for example when there're performance-critical tasks to fulfill. This can be done with Hibernate mostly, too. Sometimes it's just too memory-intensive to fetch whole entities or generated queries run too slow and you need custom SQL. Then you could use JDBC for it, although Hibernate can query the database using native SQL, too.

There're only a few cases in which I'd choose JDBC over Hibernate, as the abstraction of an ORM greatly benefits a clean programming model. For example if I was dealing with a legacy database that heavily relies on stored procedures which can't really be mapped to entities. Then it's probably better to not have the abstraction layer at all and just use a result-set oriented technology, like plain JDBC. Another point for choosing JDBC over Hibernate is when you are programming close to the relational paradigm. Objects/Entities could just be in the way of such applications. Anything that is very result-set oriented could probably be easier implemented by just using JDBC.

Conclusion

JDBC is better when:

Performance is critical (result sets are large, which is a killer for many ORMs, queries need to be fine tuned for the specific RDBMS)

You're dealing with legacy databases/applications, which were coded in a heavily result-set oriented way.

However, nearly all other cases are better covered with an ORM like Hibernate, as in modern object oriented languages the benefit of code clarity outweighs other constraints.


答:
Grab the low-hanging fruit:

I would start with security vulnerabilities.  Tell your boss that you are worried about SQL-Injection, and them demonstrate how an attacker would gain access to the system.  Once they are worried, tell them you can fix the problem.

This will give you credibility, a commodity that you'll have to have if you intend to  implement change.  Next,

I'd talk to other developers (and maybe your boss) about putting error trapping in the program, explaining that it will help in support of the software if you knew where and why things were breaking and make the company look better.

I've been in a similar environment, and this is what I've learned.

Assume an attitude of a student, and never have a superior attitude.  Some well-asked questions can cause the other developers to consider ideas they may never have even heard before.  As the junior developer, you'll get further with low-key, subtle influencing than bold strokes.

Never insult developers or their code.  Your goal is serve the company and your customers by implementing a sea-change.  Making enemies will work contrary to that goal.

Remember the line about how to eat an elephant by doing it a bite at a time.  Small incremental steps will allow the organization to digest the changes easily, without heartburn.

Don't forget that theory and practice are not always the same.  While there is no excuse for most of what you described, there are times when business needs trump design theory.  For example, fully-normalized data may be too slow for the needed performance.


问:
What do I call a non-MVC pattern?
I am finishing my project and in my thesis I am explaining why I used an MVC pattern to build my website, and have stated the advantages of designing it this way.

However, if I had not used MVC and had built my website from scratch with all the functions for data, processing, and display into each page, what would that have been called in terms of architecture?

For example, I would have had one PHP file that has all of the code and functions that it needs. Would it have been called "a standard website architecture"?

答:
The architecture that you are describing can be referred to as Model 1

In Model 1, a request is made to a JSP or servlet and then that JSP or servlet handles all responsibilities for the request, including processing the request, validating data, handling the business logic, and generating a response. The Model 1 architecture is commonly used in smaller, simple task applications due to its ease of development.

Although conceptually simple, this architecture is not conducive to large-scale application development because, inevitably, a great deal of functionality is duplicated in each JSP. Also, the Model 1 architecture unnecessarily ties together the business logic and presentation logic of the application. Combining business logic with presentation logic makes it hard to introduce a new 'view' or access point in an application...

Title: What do I call a non-MVC pattern?


问:
What causes floating point rounding errors?
I am aware that floating point arithmetic has precision problems. I usually overcome them by switching to a fixed decimal representation of the number, or simply by neglecting the error.

However, I do not know what are the causes of this inaccuracy. Why are there so many rounding issues with float numbers?

Body:
What seems to have not been mentioned so far are the concepts of an unstable algorithm and an ill-conditioned problem. I'll address the former first, as that seems to be a more frequent pitfall for novice numericists.

Consider the computation of the powers of the (reciprocal) golden ratio φ=0.61803… ; one possible way to go about it is to use the recursion formula φ^n=φ^(n-2)-φ^(n-1), starting with φ^0=1 and φ^1=φ. If you run this recursion in your favorite computing environment and compare the results with accurately evaluated powers, you'll find a slow erosion of significant figures. Here's what happens for instance in Mathematica:

ph = N[1/GoldenRatio];
Nest[Append[#1, #1[[-2]] - #1[[-1]]] & , {1, ph}, 50] - ph^Range[0, 51]
{0., 0., 1.1102230246251565*^-16, -5.551115123125783*^-17, 2.220446049250313*^-16,
-2.3592239273284576*^-16, 4.85722573273506*^-16, -7.147060721024445*^-16,
1.2073675392798577*^-15, -1.916869440954372*^-15, 3.1259717037102064*^-15,
-5.0411064211886014*^-15, 8.16837916750579*^-15, -1.3209051907825398*^-14,
2.1377864756200182*^-14, -3.458669982359108*^-14, 5.596472721011714*^-14,
-9.055131861349097*^-14, 1.465160458236081*^-13, -2.370673237795176*^-13,
3.835834102607072*^-13, -6.206507137114341*^-13, 1.004234127360273*^-12,
-1.6248848342954435*^-12, 2.6291189633497825*^-12, -4.254003796798193*^-12,
6.883122762265558*^-12, -1.1137126558640235*^-11, 1.8020249321541067*^-11,
-2.9157375879969544*^-11, 4.717762520172237*^-11, -7.633500108148015*^-11,
1.23512626283229*^-10, -1.9984762736468268*^-10, 3.233602536479646*^-10,
-5.232078810126407*^-10, 8.465681346606119*^-10, -1.3697760156732426*^-9,
2.216344150333856*^-9, -3.5861201660070964*^-9, 5.802464316340953*^-9,
-9.388584482348049*^-9, 1.5191048798689004*^-8, -2.457963328103705*^-8,
3.9770682079726053*^-8, -6.43503153607631*^-8, 1.0412099744048916*^-7,
-1.6847131280125227*^-7, 2.725923102417414*^-7, -4.4106362304299367*^-7,
7.136559332847351*^-7, -1.1547195563277288*^-6}

The purported result for φ^41 has the wrong sign, and even earlier, the computed and actual values for φ^39 share no digits in common (3.484899258054952*^-9for the computed version against the true value7.071019424062048*^-9). The algorithm is thus unstable, and one should not use this recursion formula in inexact arithmetic. This is due to the inherent nature of the recursion formula: there is a "decaying" and "growing" solution to this recursion, and trying to compute the "decaying" solution by forward solution when there is an alternative "growing" solution is begging for numerical grief. One should thus ensure that his/her numerical algorithms are stable.

Now, on to the concept of an ill-conditioned problem: even though there may be a stable way to do something numerically, it may very well be that the problem you have just cannot be solved by your algorithm. This is the fault of the problem itself, and not the solution method. The canonical example in numerics is the solution of linear equations involving the so-called "Hilbert matrix":

The matrix is the canonical example of an ill-conditioned matrix: trying to solve a system with a large Hilbert matrix might return an inaccurate solution.

Here's a Mathematica demonstration: compare the results of exact arithmetic

Table[LinearSolve[HilbertMatrix[n], HilbertMatrix[n].ConstantArray[1, n]], {n, 2, 12}]
{{1, 1}, {1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1,
  1}, {1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1,
   1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}}

and inexact arithmetic

Table[LinearSolve[N[HilbertMatrix[n]], N[HilbertMatrix[n].ConstantArray[1, n]]], {n, 2, 12}]
{{1., 1.}, {1., 1., 1.}, {1., 1., 1., 1.}, {1., 1., 1., 1., 1.},
  {1., 1., 1., 1., 1., 1.}, {1., 1., 1., 1., 1., 1., 1.},
  {1., 1., 1., 1., 1., 1., 1., 1.}, {1., 1., 1., 1., 1., 1., 1., 1., 1.},
  {1., 1., 1., 0.99997, 1.00014, 0.999618, 1.00062, 0.9994, 1.00031,
  0.999931}, {1., 1., 0.999995, 1.00006, 0.999658, 1.00122, 0.997327,
  1.00367, 0.996932, 1.00143, 0.999717}, {1., 1., 0.999986, 1.00022,
  0.998241, 1.00831, 0.975462, 1.0466, 0.94311, 1.04312, 0.981529,
  1.00342}}

(If you did try it out in Mathematica, you'll note a few error messages warning of the ill-conditioning appearing.)

In both cases, simply increasing the precision is no cure; it will only delay the inevitable erosion of figures.

This is what you might be faced with. The solutions might be difficult: for the first, either you go back to the drawing board, or wade through journals/books/whatever to find if somebody else has come up with a better solution than you have; for the second, you either give up, or reformulate your problem to something more tractable.

I'll leave you with a quote from Dianne O'Leary:

Life may toss us some ill-conditioned problems, but there is no good reason to settle for an unstable algorithm.


答:
IMO a code review should be essential for all developers, but only when the people doing the review are competent themselves.  In the past I've had code rejected in a review because, I kid you not, I followed SOLID, did some Dependency Injection and had the code organized into namespaces and folders according to the logical design, and included a small suite of unit tests to verify the code.  The code was rejected as "too complicated" and I was told to use one class that smushed everything together and remove the tests because it wasn't how the company wrote code.

A code review like that is worthless, but a code review with a competent team can often illuminate something about the design (e.g. Why you should do X and Y but not Z) or indicate an actual flaw (e.g. Doing X will cause Y to fail for incorrect reasons).


答:
Your problem is not Scrum (and as Jarrod Roberson mentioned in comments, it is not Scrum what you're describing) - it's Product Owner's micromanagement and your (and Team's) lack of assertiveness.

"However, due to scrum methodology, now many decisions simply come from product owner. He prioritizes PBIs, he analyzes how software should work, even sometimes how UI and functionality should be implemented. I know that this is part of scrum methodology."

You're mistaken. Just from a brief look at wikipedia page for Scrum one can see that: "the Team, a cross-functional group who do the actual analysis, design, implementation, testing, etc." See? Product Owner tells you what to do, but it's up to the Team to decide how to do that.

You are the person responsible for implementation, so you should decide how the application is going to be implemented. Listen to the Product Owner's opinion, but the final decision is up to you (or the Team).

BTW micromanagement does turn active developers into passive developers.


答:
Of course Code Review isn't needed.  Then again, neither are tests, continuous integration, source control, customer involvement, profiling, static analysis, decent hardware, one-click builds, bug tracking, the list goes on.

Along with Code Reviews, the things I mention above are tools that help ensure software quality.  With a combination of skill, luck, time and determination; you can deliver quality software without any of this stuff, but it's more likely that you won't.

In your scenario, there is nothing to be confused about.  Not every organisation indulges in every best practice.  They may disagree with it, it may conflict with a different best practice that they do implement, or they may consider that the overhead of implementing it is too great for them at this point in time.  Depending on their circumstances, they may be correct in doing so, or they may be making a false economy.  For some tools, (e.g. source control) the payback/effort ratio is so good that using it is a no-brainer; for others it's less clear.

There is no doubt that code review is a practice that introduces a significant overhead. Because of this, organisations will seek to minimise that overhead, either by not doing it at all, or by only doing it in certain situations (e.g. for a junior team member, or a particularly hairy change).  It is not always obvious that it pays back more (in catching bugs,   reducing technical debt or sharing knowledge) than it costs.  Most of that payback is difficult to quantify, whereas its very easy to count the number of man-hours your organisation spends doing reviews.  The easiest bit to quantify (reduced bug count) is easy to attribute to other factors (e.g. "of course it has fewer bugs, it's more mature").


答:
We practise Scrum here. We have a fortnightly planning meeting where we feed in the current business priorities, and successes and failures from the previous sprint, and we decide, as a team, what we want to tackle for the next sprint.

One of the ways we do this is to sort the backlog on a board by complexity vertically, and business priority horizontally. After that, the Product Owner has had his input, so it's up to the team to pick off what we want to do. Obviously, picking off a high-complexity low-priority task is frowned upon, but we are deciding this as a team. It makes planning sessions longer, but it's worth it, and a core part of the Agile process.

And we do have micro-management sometimes, but that's a different problem.


答:
In my opinion, code that is going to be used by a company, whether it was written by a Junior or Senior developer, should always be reviewed. Why? Because what if the code had several bugs? And what if, during the time this code was being used, the program crashed? To stop these things from happening, all code should be reviewed before use.

But what about those companies that don't review code? They're probably the companies that have lots of tech problems and lots of, as they tell consumers, "crashes" ;-).

So let me answer all of your questions:

Yes the Review Process is necessary.

Why? Because of the reasons I stated above.


答: The Role of Leaders on a Self-Organizing Team would be a blog post about something that seems to be missing from your post.  Where is the team deciding what work gets done in a sprint?  Where is the team having ownership in the process and the work?  Do you have someone that knows Scrum enough that you are doing Scrum and not some perverted version of it?</p>

ContentLicense: CC BY-SA 4.0


答:
Would it be 1 php file?

Wouldn't it be more likely to be many php files, each file containing the html content and php code?

If so then the architecture would be called 'Page Controller' as apposed to the 'Front Controller' typically found in mvc.

Title: What do I call a non-MVC pattern?

Body:
I am finishing my project and in my thesis I am explaining why I used an MVC pattern to build my website, and have stated the advantages of designing it this way.

However, if I had not used MVC and had built my website from scratch with all the functions for data, processing, and display into each page, what would that have been called in terms of architecture?

For example, I would have had one PHP file that has all of the code and functions that it needs. Would it have been called "a standard website architecture"?


答:
In Scrum there is plenty of space for the developers to contribute and give their advice on new features, UI, usability... Collaboration and conversation between business people and developers is required in Scrum and it allows that. However in the end the product owner will always have the final say because he's the one responsible for maximizing the business value of the software increments produced sprint after sprint (in other words, the ROI).

From the Agile Manifesto :

Our highest priority is to satisfy the customer through early and
  continuous delivery of valuable software.

The product owner telling you how UI and functionality must be implemented isn't acceptable though. In that case you should have the final say since you are responsible for the internal quality of the software you produce.

Maybe you work in a company created by developers where programmers had freedom to implement whichever features they wanted. However, most Agile methodologies make a clear separation between business domain people and the team responsible for producing software (developers, testers...) which is the most common work division in most places. If my assumptions are right, I can understand the feeling you have that you're not able to "have an influence on the big picture" anymore but with the company growing I guess that would have been the case anyway, Scrum or not.

Regarding analysis, design and other meta-development activities you mention (which again are not supposed to be done by the Product Owner), Agile teams are supposed to be cross-functional and silo-free. No one is supposed to possess all the knowledge around one specific development activity, so maybe there's an opportunity for you to diversify there vs just "code monkeying".


问:
Is it practical to use Twitter for service logs?
Recently my boss suggested that we post logs of our service that is hosted on Windows Azure into twitter. His idea is that it's conveniently readable and if Azure cloud fails logs persist. He also said, lots of people do this, I Googled and couldn't find any data about this.

Currenly my concerns are the following. First, perhaps twitter is not very convenient for logging something that can happen very frequently (for example, when our service role starts each instance writes tens of records over several minutes). Second, even if twitter EULA allows such use at this moment it might be changed in future to cut off tweets that occur too often to be human-originated.

Is it practical to post service logs on twitter? What to consider if we implement this?

答: Or you can use an Open source implementation twitter like Status.net et make available only for admins. </p>


问:
Working for free?
I came across this article Work for Free that got me thinking.

The goal of every employer is to gain
  more value from workers than the firm
  pays out in wages; otherwise, there is
  no growth, no advance, and no
  advantage for the employer.
  Conversely, the goal of every employee
  should be to contribute more to the
  firm than he or she receives in wages,
  and thereby provide a solid rationale
  for receiving raises and advancement
  in the firm.

I don't need to tell you that the
  refusenik didn't last long in this
  job.

In contrast, here is a story from last
  week. My phone rang. It was the
  employment division of a major
  university. The man on the phone was
  inquiring about the performance of a
  person who did some site work on
  Mises.org last year. I was able to
  tell him about a remarkable young man
  who swung into action during a crisis,
  and how he worked three 19-hour days,
  three days in a row, how he learned
  new software with diligence, how he
  kept his cool, how he navigated his
  way with grace and expertise amidst
  some 80 different third-party plug-ins
  and databases, how he saw his way
  around the inevitable problems, how he
  assumed responsibility for the
  results, and much more.

What I didn't tell the interviewer was
  that this person did all this without
  asking for any payment. Did that fact
  influence my report on his
  performance? I'm not entirely sure,
  but the interviewer probably sensed in
  my voice my sense of awe toward what
  this person had done for the Mises
  Institute. The interviewer told me
  that he had written down 15 different
  questions to ask me but that I had
  answered them all already in the
  course of my monologue, and that he
  was thrilled to hear all these
  specifics.

The person was offered the job. He had
  done a very wise thing; he had earned
  a devotee for life.

The harder the economic times, the
  more employers need to know what they
  are getting when they hire someone.
  The job applications pour in by the
  buckets, all padded with degrees and
  made to look as impressive as
  possible. It's all just paper. What
  matters today is what a person can do
  for a firm. The resume becomes pro
  forma but not decisive under these
  conditions. But for a former boss or
  manager to rave about you to a
  potential employer? That's worth
  everything.

What do you think? Has anyone here worked for free? If so, has it benefited you in any way? Why should(nt) you work for free (presuming you have the money from other means to keep you going)? Can you share your experience?

Me, I am taking a year out of college and haven't gotten a degree yet so that's probably why most of my job applications are getting ignored. So im thinking about working for free for the experience?

答: Source: http://shouldiworkforfree.com/

Title: Working for free?

Body: Source: http://shouldiworkforfree.com/


问:
Programming as a conversation
I have often wondered if it would be possible to write a programming language that would work as a conversation. I would tell the computer that I want to store coordinates and it would ask what representation I would use. I would then ask to find the shortest path between points and it would ask if I want to use Djkstra's, brute force or use Floyd's? What research has been done towards producing a system like this?</p>

答: Intellisense/CodeAssist feature in modern IDEs come to mind as the closest thing in current software practice to your requirements... whereby you discover the capabilities of the system as you type in code. It allows you to navigate the feature-space of the development platform in real time. Its not exactly the same as you describe but comes pleasantly close enough.</p>

Title: Programming as a conversation


答: I think "monolithic" would be the term here. To my mind this implies no separation of concerns or layering, which is what you are describing.</p>

Title: What do I call a non-MVC pattern?


问:
What features in Eclipse is not available in Visual Studio?
I have done much development in Java using Eclipse, and now I have started to use Visual Studio for .NET development. So far I find the IDEs to be able to do the same things, but just different.

What features in Eclipse isn't available in Visual Studio?

答:
I don't remember Visual Studio having something similar to Eclipse working sets.

Working sets - Help - Eclipse SDK

They are a way to group projects included in your 'solution' (workspace in Eclipse) in a way that allows you to hide or show different sets of projects according to the part of the code on which you want to work. For example, you could define a working set containing only the unit test projects, or only the data access layer related modules in your project.

It is useful to filter almost any Eclipse View to show only the stuff related to the currently selected working set. For example, the error list: you don't have to see all the errors in the workspace, only the ones related to the projects in the active working set.

The only way I imagine duplicating this functionality in Visual Studio is having a multiple solution approach, and opening and closing solutions manually.


问:
Simplified knapsack in PHP
I have two instances where I'd like to display information in a "justified" alignment - but I don't care if the values are switched in order. One example being displaying the usernames of people online:

Anton Brother68 Commissar Dougheater Elflord Foobar Goop Hoo Iee Joo

Rearranging them we could get exactly 22 characters long on each line:

```<code>Anton Brother68 Foobar
Commissar Elflord Goop
Dougheater Hoo Iee Joo
</code>```

This is kind of a knapsack, except seems like there ought to be a P solution since I don't care about perfection, and I have multiple lines.

Second instance is identical, except instead of names and character count I would be displaying random images and use their width.

答:
It doesn't feel like a knapsack problem because the utlity of all words placed is 1 (correct me if I'm wrong).

Perhaps binpacking instead?

Title: Simplified knapsack in PHP


答:
Personally, I find KEYWORDS THAT SHOUT to be calling attention to
  exactly the wrong part of the query, which is why I write the keywords
  in lowercase.

As has been pointed out, with old IDE's you didn't have many options besides casing to differentiate text.  As you point out, making the keywords stand out draws your attention away from where it should be.  The issue is that you know keywords can always be capitalized, whereas the other stuff can contain literals and identifiers that are case sensitive.  This lead to the path of least resistance being to just capitalize the keywords.

Title: What good reasons are there to capitalise SQL keywords?

Body:
There seem to be a lot of developers who write their SQL by capitalising the keywords:

```<code>SELECT column
FROM table
     INNER JOIN table
     ON condition
WHERE condition
GROUP BY clause
HAVING condition
</code>```

I'm wondering why people stick to this approach? Clearly, it's a long established convention - but I've never run into a RDBMS that requires capitalisation.

Personally, I find KEYWORDS THAT SHOUT to be calling attention to exactly the wrong part of the query, which is why I write the keywords in lowercase.

Still, enough people use this convention that I figure I might be missing something, hence this question.


问:
Does Scrum turn active developers into passive developers?
I'm a web developer working in a team of three developers and one designer. It's now about five months that we've implemented the agile scrum software development methodology. But I have a weird feeling I just wanted to share in this site.

One important factor in human life is decision-making process. However, there is a big difference in decisions you make. Some decisions are just the outcome of an internal or external force, while other decisions are completely based on your free will, and some decisions are simply something in between. The more freedom you have in making decisions, the more self-driven your work would become. This seems to be a rule. Because we tend to shape our lives ourselves.

There is a big difference between you deciding what to do, or being told what to do.

Before scrum, I felt like having more freedom in making the decisions which were related to development, analysis, prioritizing implementation, etc. I had more feeling like I'm deciding what I'm doing.

However, due to the scrum methodology, now many decisions simply come from the product owner. He prioritizes PBIs, he analyzes how the software should work, even sometimes how the UI and functionality should be implemented. I know that this is part of the scrum methodology, and I also know that this may result in better sales of product in future. However, I now feel like I'm always getting told to do something, instead of deciding to do something. This syndrome now has made me more passive towards the work.

I tend to search less to find a better solution, approach, or technique

I don't wake up in the morning expecting to get to an enjoyable work. Rather, I feel like being forced to work in order to live

I have more hunger to work on my own hobby projects after work

I won't push the team anymore to get to the higher technological levels

I spend more time now on dinner, or tea-times and have less enthusiasm to get back to work

I'm now willing more for the work to finish sooner, so that I can get home

The big problem is, I see and diagnose this behavior in my colleagues too. Is it the outcome of scrum? Does scrum really makes the development team feel like they have no part in forming the overall software, thus making the passive to the project?
How can I overcome this feeling?

答:
The real problem you're describing is a common pathology when teams adopt a Methodology: they turn off their brains. This is as true with a new-school agile system as it was with old-school heavyweight systems.

Q: The Methodology prescribes x, but x isn't working well. What should we do?

A: Refine your implementation of x. Maybe stop doing it altogether. The Methodology isn't the boss of you!

In this specific case, it sounds like the product owner might be doing too much. Are you comfortable talking to him about that? Would you be comfortable having that conversation if you weren't "doing scrum?" If the product owner isn't sensitive to constructive feedback, it's not a methodology problem, it's a problem with the product owner.