答:
I'm curious why a combination of the two isn't a viable option. Right now you trigger jobs on page views, with some unlucky sap getting stuck waiting 10 seconds for the page to come up. At least that's my understanding of your current method.

However those jobs are taking longer and longer to run as the site grows, and you don't want to derail the user experience on the site. Not even for a few (Or maybe a lot) unlucky users through out the day, so now you're thinking about scheduling jobs in the background.

I don't see why a background job run at regular intervals can't mimic a visitor. Now I'm not a Windows programmer, but in the Linux world I would set up a cron job that runs at a regular interval, and it would have 2 lines of code.

```<code>#!/bin/bash
wget -O /dev/null http://stackoverflow.com/specially_crafted_url
</code>```

It combines the pros of both systems. It's done in the background. It doesn't effect users. It still uses a page view to kick off the job. I've seen this approach used before. It tends to be the middle ground between the simple ways of old, and the more complex ways coming down the road.

Update

I think you can get around the load balancing issue by running the job runners on the web servers themselves. The job runner pulls a URL out of the job queue, and runs it like so:

```<code>wget -O /dev/null http://localhost/specially_crafted_url
</code>```

Because of the nature of job/messaging queues, the jobs will get evenly distributed among the job runners, which means the specially_crafted_url is eventually distributed among your web servers.

Body:
We're dealing with an interesting problem on StackOverflow.

We've got a whole bunch of little "needs to be done soon-ish" tasks.  An example is updating "Related Questions" lists.  What we've done in the past is to piggy-back those tasks onto some users' page loads.

This was never ideal, but it wasn't really noticeable.  Now that SO has passed the 1,000,000 question mark, those unlucky users are starting to feel it.

The natural solution is to actually push these tasks into the background.  There are two broad ways of doing this I'm considering.

1. In IIS as a custom Thread-Pool/Work-Queue

Basically, we spin up a few (non-ThreadPool, so as to not interfere with IIS) threads and have them services some collections we're shoving Funcs into.

The big pro here is simplicity.  We don't have to worry about marshaling anything, nor do we have to make sure some external service is up and responding.

We also get access to all of our common code.

The con is, well, that we shouldn't use background threads.  The objections I know of are all centered around starving IIS (if you use ThreadPool) and the threads dieing randomly (due to AppPool recycling).

We've got existing infrastructure to make the random thread death a non-issue (its possible to detect a task has been abandoned, basically), and limiting the number of threads (and using non-ThreadPool threads) isn't difficult either.

Am I missing any other objections to in IIS process thread-pooling/work-queues?

Moved to StackOverflow, as it wasn't really addressed here.

2. As a Service

Either some third-party solution, or a custom one.

Basically, we'd marshal a task across the process boundary to some service and just forget about it.  Presumably we're linking some code in, or restricted to raw SQL + a connection string.

The pro is that its the "right way" to do this.

The cons are that we're either very restricted in what we can do, or we're going to have to work out some system for keeping this service in sync with our code base.  We'll also need to hook all of our monitoring and error logging up somehow, which we get for free with the "In IIS" option.

Are there any other benefits or problems with the service approach?

In a nutshell, are there unforseen and insurmountable problems that make approach #1 unworkable and if so are there any good third-party services we should look into for approach #2?

Body:
I'm curious why a combination of the two isn't a viable option. Right now you trigger jobs on page views, with some unlucky sap getting stuck waiting 10 seconds for the page to come up. At least that's my understanding of your current method.

However those jobs are taking longer and longer to run as the site grows, and you don't want to derail the user experience on the site. Not even for a few (Or maybe a lot) unlucky users through out the day, so now you're thinking about scheduling jobs in the background.

I don't see why a background job run at regular intervals can't mimic a visitor. Now I'm not a Windows programmer, but in the Linux world I would set up a cron job that runs at a regular interval, and it would have 2 lines of code.

#!/bin/bash
wget -O /dev/null http://stackoverflow.com/specially_crafted_url

It combines the pros of both systems. It's done in the background. It doesn't effect users. It still uses a page view to kick off the job. I've seen this approach used before. It tends to be the middle ground between the simple ways of old, and the more complex ways coming down the road.

Update

I think you can get around the load balancing issue by running the job runners on the web servers themselves. The job runner pulls a URL out of the job queue, and runs it like so:

wget -O /dev/null http://localhost/specially_crafted_url

Because of the nature of job/messaging queues, the jobs will get evenly distributed among the job runners, which means the specially_crafted_url is eventually distributed among your web servers.


问:
How useful is a project log or diary?
I want to know how difficult/useful it is to keep a project log or diary. I'm worried that keeping track of what I did will eat up too much time...</p>

答:
Although this is a pretty general question, I think the answer comes down to how valuable you see self-reflection.

If the ability to look back on progress is more valuable to you than working through whatever time it would take you to make some notes on progress, I would say it's a worthwhile activity.

I think, as a programmer working on a piece of software, it is nice to have some log of progress and steps taken (similar to version control notes) to keep track of changes you made, where you made them, and why. Very useful information when troubleshooting and when tackling similar pro

That being said, it's not difficult. It's just more helpful if you can do it regularly, and that is assisted by getting into a routine for most people.

ContentLicense: CC BY-SA 3.0

Title: How useful is a project log or diary?


答:
I'm worried that keeping track of what I did will eat up too much time...

I worry about the opposite. I oftentimes find that the cost of not documenting something eats up even more of my time. Maybe it doesn't happen today. Maybe not tomorrow, but at some point most of the things that I have done have come up again at some point, and it generally happens after enough time has passed for my brain to consider it unimportant.

Thus, I document things. I document decisions I've made, agreements made with team members, and most importantly, I document my code, even if it just involves using keywords to make it easier to grep the project for a certain function or line of code.

In some cases, the documentation has saved others' time as well. It's these cases where the X minutes spent documenting became an investment in itself where the X minutes invested gave a Y*X minute return in time savings!

Lastly, in other cases, I've found documenting work helps me remember it. In some cases, I never looked at the documentation again because for me, writing something down is a catalyst for burning it into my memory.

Everyone is different, and you'll need to find what works for you. As for me, I can't say that I've regretted time spent documenting my work, but I sure as heck have regretted the times I haven't.

Title: How useful is a project log or diary?

Body: I want to know how difficult/useful it is to keep a project log or diary. I'm worried that keeping track of what I did will eat up too much time...</p>


问:
Why is subclassing too much bad (and hence why should we use prototypes to do away with it)?
I was reading up on design patterns, and I read that the prototype design pattern does away with excessive subclassing.

Why is subclassing bad? What advantage would using a prototype bring about over subclassing?

答:
I think one of the reasons this has been viewed as a bad practice is that over time each subclass can contain attributes and methods that make no sense for that object the further you go down the chain (in a poorly developed hierarchy).  You can end up with a bloated class that contains items that don't make sense for that class.

I'm agnostic about this myself.  It seems dogmatic to just say it's bad.  Anything is bad when misused.


答:
Two reasons.

Is runtime performance. Everytime you invoke a subclass from a superclass you are doing a method call so if you have nested five classes and invoke a method in the base class you will be doing five method invocations. Most compilers/runtimes will try to recognose this and optimise the extra calls away but it is only safe to do this for very simple cases.

Is the sanity of your fellow programmers. If you nest five classes I have to examine all four parent classes to establish you are really calling a method in the base class, it gets tedious. I may also have to step through five method invocations when I debug the program.

Title: Why is subclassing too much bad (and hence why should we use prototypes to do away with it)?

Body:
I was reading up on design patterns, and I read that the prototype design pattern does away with excessive subclassing.

Why is subclassing bad? What advantage would using a prototype bring about over subclassing?


答:
Why is subclassing too much bad

"Too much" is a judgement call; but take it from me it is bad. The code I work with has DEEP inheritance and the code is just damn hard to read, understand, follow, trace, debug, etc. etc. It is effectively impossible to write test code for this stuff.

Prototype pattern does away with subclassing

Or does the question mean "does away with too much subclassing?".  This pattern calls for cloning a "template" object to avoid subclassing, at least at that point. There's no rule that says the "template" can't be a subclass.

Favor composition over inheritance

This idea here also includes delegation and aggregation. Following this heuristic means your software tends to be more flexible, easier to maintain, extend, and reuse.

When a class is composed of parts you can substitute those parts at runtime. This has a profound effect on testability.

Testing is easier. You can use fake parts (i.e. "mocks", "doubles" and other testing-talk).  Our code's deep inheritance means we must instantiate the entire hierarchy to test any bit of it. In our case that is not possible without running the code in it's real environment. For example we need a database in order to instantiate business objects.

Changes come with side effects and uncertainty -  The more "base" the class the more widespread the effects, for good or bad. There may be desired changes you dare not make due to side effects uncertainty. Or a change that is good for some place in our inheritance chain is bad for another. This is certainly my experience.


答:
I've been using a personal wiki for about 7 years now, Wiki on a Stick or WoaS: http://stickwiki.sourceforge.net/

I created a knowledge base for all the software I support, links to numerous technical resources, team meeting notes - all of those are phone conferences, documenting development environment, and technical and professional goals, todo lists, etc. Practically anything I'd write on a notepad or sticky goes in this wiki. Using Firefox from http://portableapps.com, my entire wiki is self contained, doesn't require a server or installing any software on the client computer. Works cross platform too. Only issue I've had is using Chrome. It won't save any changes. Firefox has worked the best so I stick with it.

There have been several times a project was back-burnered only to have it resurrected 9 months later. WoaS brought me back where I left off and was productive without trying to remember what I had previously done or what happened to the notepad I was using back then.

I've never regretted taking the time to document my work. After some practice it really doesn't take a significant amount of time to keep notes. If you can develop a process that's simple yet affective,  you'll be more likely to do it.

Title: How useful is a project log or diary?


问:
Should I use Legitimate Email spoofing?
Recently I receive a request: users' emails are stored in the database, and as request of a user, the system will send an email on their behalves.

To add more context, it's like sending an email from the vendor, to their customers' email addresses. But it's not a fixed email (it depends on which vendor ask the system).

Using JavaMail, I can simply set the from field. But something doesn't seem right. When searching for this kind of work, I come across "Email spoofing" - which looks like what I'm going to do. There are some drawbacks for this approach, such as it may make the emails attractive to the spam filters, and so on...

Ofcourse I can just do as the client want, but I just wonder, is there any better alternative?

答: So long as it's at the user's request, there's nothing questionable about doing this.  It's just like your system is the email client.  Sending emails from an address without the address owner's approval is a different story, of course.</p>

Title: Should I use Legitimate Email spoofing?


问:
In scrum, how do you use "usability testing" in team?
I am currently reading some material by Jeff Patton regarding Agile and UX.

http://www.agileproductdesign.com/presentations/index.html

I was interested to find out from the community what UX design and testing behaviors seemed MOST helpful to their scrum teams to create GREAT and delightful products.

hallway usability?

paper prototypes?

seeing how users actually use the software?

others?

Thanks!

答:
Most important: Have a UX designer in the team from the beginning of the project

Paper prototypes: Cheap, quick, easy and you don't get lost in the
details.

Hallway usability tests: Just gather thoughts from
different perspectives

Tests with potential real users: Nothing
more valuable than the real end users

AB testing: Test 2 different designs/menus/layouts/workflows. Measure usage. Decide which one to use.

OwnerDisplayName: Michael Rosario

OwnerDisplayName: Peter Gfader


答:
The activities you mentioned center around a verification of an UX design to see if it has met objectives/requirement and if it pleases the customer or not. Any or all of them should give you a clue on how well the design is done. I also agree with Albin that design and verification approaches really depends on a whole lot of different factors.

If you are concern with the "done" in Scrum you have to not only achieve a design that meets customer requirements but also upheld the quality of deliverable in current and future sprint (releases). UX testing can be painful but unfortunately you must be able to test and test well to build quality software.

Title: In scrum, how do you use "usability testing" in team?

Body:
I am currently reading some material by Jeff Patton regarding Agile and UX.

http://www.agileproductdesign.com/presentations/index.html

I was interested to find out from the community what UX design and testing behaviors seemed MOST helpful to their scrum teams to create GREAT and delightful products.

hallway usability?

paper prototypes?

seeing how users actually use the software?

others?

Thanks!

OwnerDisplayName: cchou


问:
A Class named Class?
This is more of a style question, but it is something I am currently pondering for a project of mine.

Assume that you're creating an application which is modeling a school. So there are entities like Student, School, etc. Now this is all fine and intuitive until you get down to Class, as (in most languages) Class is a reserved word. So, given that Class is a reserved keyword, what would you call such an entity that models a school class?

答: It depends, in some languages class is the reserved word, not Class.

Title: A Class named Class?


答:
It's a piece of literature.

Like the ancient times, knowledge was best preserved when written. "Oral Tradition" isn't that effective.

It's a sign of maturity when one does this. To answer your question: it is very useful. You will never who's gonna read your work in the future. It's a good contribution.

Title: How useful is a project log or diary?


答:
I'd pick another term because the word Class can be ambiguous.

Does class refer to:

The group of students taking a course?

The whole course for this semester?

The abstract course taught in multiple semesters?

The group of students expected to graduate at a specific time?

Some other classification of students, i.e. Advanced Class, Special Needs class.

A specific lecture

And that's without even leaving the academic realm. Chances are you can find a better word to fit whatever you are trying to model. Class will only lead to some confusion.

Title: A Class named Class?

Body:
This is more of a style question, but it is something I am currently pondering for a project of mine.

Assume that you're creating an application which is modeling a school. So there are entities like Student, School, etc. Now this is all fine and intuitive until you get down to Class, as (in most languages) Class is a reserved word. So, given that Class is a reserved keyword, what would you call such an entity that models a school class?


问:
Jython and JRuby vs. Groovy (and Java)
I am very interested in Python for programming on the JVM, and I've worked in Java and Ruby (not JRuby) a lot, and to a certain extent in Groovy.

What are the limits to the Java-Jython and Java-JRuby integration right now? What about Groovy: are there any things that a Java class can do that a Groovy class cannot? And what about IDE integration (mostly Eclipse, but IntelliJ and Netbeans are also interesting)?

I'm not interested in whether Python, Ruby or Groovy is better/more-concise/whatever. I'm just interested in how well they are working in the JVM and tools (especially IDEs) right now. My main interest is not inside a web server, if that matters.

Simple examples of getting a HelloWorld which extends a custom Java class and implements a custom Java interface would be very useful to me.

答:
I have no experience of JRuby nor Groovy. But Jython:

Excellent integration with NetBeans. NetBeans can run Python programs with Jython almost straight out of the box, just install the "Jython Distribution" plugin and you're done. Apparently Eclipse works as well. See chapter Using Jython in an IDE in the Jython Book.

Java-Jython integration is excellent. Calling Java from Jython is super easy. Calling Jython from Java is not quite as straightforward (Java was not designed with Jython in mind), but still fairly easy. I've mostly had luck with creating a class in Jython (extending a Java class/interface), and then creating instances of that class in Java using an object factory. See Jython and Java Integration for how-to.

Extending a Java class in Jython works like this:

```<code>from javax.swing import JFrame, JButton

class MyFrame(JFrame):

    def __init__(self):
        self.defaultCloseOperation = JFrame.EXIT_ON_CLOSE
        self.size = (300, 300)
        self.add(JButton('Click Me!', actionPerformed=self.print_something))
        self.visible = True

    def print_something(self, event):
        print 'Clicked!'
</code>```

Implementing interfaces works similarly, just import the interface, "extend" it using a class definition such as class MyClass(MyInterface) and implement what's needed.

My only criticism against Jython is that its raw performance is not very good (and that's mostly because it uses massive reflection to interact with Java). But then, raw performance is usually pretty irrelevant for a scripting language.

ContentLicense: CC BY-SA 2.5

Title: Jython and JRuby vs. Groovy (and Java)

Body:
I have no experience of JRuby nor Groovy. But Jython:

Excellent integration with NetBeans. NetBeans can run Python programs with Jython almost straight out of the box, just install the "Jython Distribution" plugin and you're done. Apparently Eclipse works as well. See chapter Using Jython in an IDE in the Jython Book.

Java-Jython integration is excellent. Calling Java from Jython is super easy. Calling Jython from Java is not quite as straightforward (Java was not designed with Jython in mind), but still fairly easy. I've mostly had luck with creating a class in Jython (extending a Java class/interface), and then creating instances of that class in Java using an object factory. See Jython and Java Integration for how-to.

Extending a Java class in Jython works like this:

from javax.swing import JFrame, JButton

class MyFrame(JFrame):

    def __init__(self):
        self.defaultCloseOperation = JFrame.EXIT_ON_CLOSE
        self.size = (300, 300)
        self.add(JButton('Click Me!', actionPerformed=self.print_something))
        self.visible = True

    def print_something(self, event):
        print 'Clicked!'

Implementing interfaces works similarly, just import the interface, "extend" it using a class definition such as class MyClass(MyInterface) and implement what's needed.

My only criticism against Jython is that its raw performance is not very good (and that's mostly because it uses massive reflection to interact with Java). But then, raw performance is usually pretty irrelevant for a scripting language.


答:
You could name it a "Course," or a "Subject," or a "Lecture" if it is a specific class. You could also use "Section," etc.

Winston Ewert really highlighted the questions you would have to ask yourself.

Title: A Class named Class?


问:
What were the historical conditions that led to object oriented programming becoming a major programming paradigm?
What were some of the economic (and other historical) factors that led to object oriented programming languages becoming influential? I know that Simula started things off, but was the adoption of OOP languages due to the ever increasing needs of business? Or, was the adoption due more to the new things that could be done with OOP languages?

Edit
I'm really most interested in whether there was some factors going on external to the languages themselves that allowed for them to take hold.

答:
I see OOP as a natural evolutionary step from procedural code:

Procedural code: Tell the machine to do A, then tell it to do B.

OOP: Package the procedural instructions into very reusable chunks, by defining interfaces/input/outputs. (Warning: simplification.)

I'm sure someone with a wider view will chime in, but it seems like this was a natural progression in simply allowing programmers to produce code faster: i.e. allow greater code reuse.

In this view, the biggest external factor was reduced cost of processor horsepower (versus developer labor cost to create typical programs): computing overhead in using OOP classes became less of a concern than the developer time savings. (This same tradeoff of CPU expense versus programmer expense has influenced many other aspects of programming.)

OwnerDisplayName: ihtkwot


问:
Should developers be expected to compile an internal library before the actual program?
Recently a senior developer that I work with made a case for requiring that developers get the latest version and compile as part of their project a major internal library. This stands in contrast the the counter argument that project teams should be working off a stable version that they get from an internal Maven repository; to which the developer argued that having the source code available on the developer machines saves time, as they can read the library's source code to determine if required functionality is available.

Does the senior developer have a valid argument? Or is requiring developers to read the library's source code run counter to the basic philosophy of encapsulation, and even having the library in the first place?

答:
Since so many people answered that it makes no sense to have everyone build an internal library, I'll present the opposite viewpoint which could justify the reasons:

You use the library a lot and there's no documentation. So everyone should have the source for reference. If this is a library that gets used very frequently, having the reference handy could be useful

Sure, one would say that they should work on documentation and more than likely your senior developer is aware of this fact.  But let's face reality, a lot of times development teams end up with a ton of undocumented code, so when you need to know how it works, you go to the source.  You shouldn't have to do it, but in the short term, this is the best alternative.

Usually the best people to put documentation in place are those that know the library the best. Unfortunately, those are the same people who are typically the busiest, so it's often not that easy for them to drop everything and start documenting.

When people start writing their own code that depends on the library and something in the library doesn't work, instead of throwing their arms in the air, if the library is built locally, it becomes very easy to step right inside the library code

This can occur because many libraries are far from perfect and while we all want to work with a "stable" release, there can still be issues.

Maybe you are getting bad results because of misunderstanding how an API should be used. Even with documentation, people often make wrong assumptions

Your senior guy is probably tired of new people (and sometimes there's a lot more new people than those that know the project inside and out) throwing their arms in the air whenever a crash/some other error seems to come from a library code.  So instead of having to come over to your machine and then to the guy sitting next to you, they want the option of responding with these questions: 1) where exactly is the crash? what module/file/line? 2) have you debugged it? what have YOU found?

Your senior guys worked with this code base (application and your major library) long enough and potentially he may have noticed that when the code is already on the machine and is ready to be debugged and stepped through, it makes his life easier and gets people to learn the code base faster.  So for that reason he forces you to take the upfront cost of building the library on your machine.

I'm not saying his decision is justified, just pointing out that a) question presented one side of the story and b) there could be plausible motives.

ContentLicense: CC BY-SA 4.0


答:
Short answer

I think it was the churn of software projects prior to OO days. OO helped by adding the fundamentally critical concept - Model the real world .

The first object oriented programming language was Simula way back in 1967. However, at that time software development at large was still in the labs more and most paradigms were still closer to hardware case.

Over a full another decade development of software for enterprise applications other commercial applications grew and software development at large picked up over the entire 1970's. Languages that still survives today of those age (prior to 1980) were C, Cobol, Fortran and similar other. Most of these languages are procedural. Lisp also existed since that day - however, i am not sure if that was prominent general purpose language for commercial development. The famous term Waterfall model was also coined in the early 1970's era.

In most commercial environment most important element emerge in software development was project management. There was a dire need for tight and at least predictable budgets and managing requirements to freeze to ensure that project reaches the finish line respectably. During this period was also one of the Mythical Manmonths back in 1975.

I guess by end of 70's people were burnt out - as procedural languages didn't keep up to those promises. And a new paradigm Object oriented which did existed since that time made it big. Though people might disagree, i think the C++ which help familiarity and proven experience and of C, and the Promise of Object orientation (originally with the name C with Classes) back in 1983 was a corner stone to the success of Object oriented programming.

Some reference for more perspective - http://journal.thedacs.com/issue/43/88

So why OO?

I think those days (if you look at the project success point of view) - it made sense that what you can understand better will be manageable better. Object oriented methodology with a promise "..everything in life is an object" seemed more like commonsense even before it was proven to be meaningful. The practical success of this factor was the very notion to sufficiently model the real world and problem at hand before jumping the gun - which i think something fundamentally new thing that OO offered which no other paradigm offered till that date. And definitely given that this paradigm forced you to somewhat think before you code more than procedural languages it showed visible success on the software projects that employed and since then they caught on!

EDIT

I would also add that programming languages evolved simultaneously in parallel to such fundamental concepts (OO paradigm, Aspect, Virtual machines, ) Each new concept and fresh thinking emerged only when a fresh new programming languages mastered it - keep only familiarity but change fundamentals from core! At the same time - these new concept and new languages only emerged because of new business problems. 1980's - OO for large scale software, 1990 Java in Internet age, PHP/ASP and many other for web. Innovation in programming languages were also driven mostly by discontinuous market need.

In summary, early 80s' was the age where larger scale commercial software took off - while projects with procedural languages had their problems, OO showed the better light and made projects more successful.

Title: What were the historical conditions that led to object oriented programming becoming a major programming paradigm?

Body:
What were some of the economic (and other historical) factors that led to object oriented programming languages becoming influential? I know that Simula started things off, but was the adoption of OOP languages due to the ever increasing needs of business? Or, was the adoption due more to the new things that could be done with OOP languages?

Edit
I'm really most interested in whether there was some factors going on external to the languages themselves that allowed for them to take hold.


问:
The overlap between open source and closed source
I would like to understand why do some people like open source and some others like closed source? Let me be more specific and make my question about web development. If I build my site using an open source server side language what are the benefits for me? and if I build it using a closed source server side language, what are benefits?

I just want to understand how can I choose between the two differnt paradigms when building different types of web sites and applications!

答:
This has probably been discussed to death, but...

Choosing between an open-source and a closed-source language probably won't matter much to you. However, choosing between an open-source and a closed-source framework might.

For example, if you found a bug in the framework, and it was open source, well the code's right there. Go look at it, fix the bug, tell the developers, and carry on with your day. Closed source? Well, hopefully the project's owners are willing to take a look.

With that said, usually it doesn't matter. You should choose based on the language or framework's community, featureset, and ability to accomplish what you want to do.


问:
Testing chainable method calls return type and value
Is it worth testing the return type and value of a method call that is designed for chaining? It is conceivable that a fellow programmer could accidentally change the return type to void and remove the return while furiously refactoring some methods? This would potentially break a lot of code for an unsuspecting user. </p>

<p>However, I feel like I would be testing code structure rather than code functionality. Is this a reasonable thing to test? Or is it just a big waste of time?  </p>

答:
If the chainable method constitutes a unit, then by all means unit-test it. If it is only used internally, and thus easily subject to refactoring, leave it alone and unit-test the exposed methods that use it instead.

Pragmatically speaking, if other code relies on the return type being correct, then naively changing it will break your build anyway, unless you also change the dependent code - but then, if you do that, you probably know exactly what you're doing. But then, writing such a test is trivial, so the only reason for not testing would be that you want people to change the return type at will.


答:
Outlook knows when I sent mail from GMail using a different address than that of my GMail account. It shows them as From  on Behalf of . Outlook can only know this if GMail sends more headers than just the "From". And indeed it does. In the headers of an e-mail I sent in this manner, I can see:

```<code>Return-Path: GMail account
Sender: GMail account
From: Marjan Venema <other account>
</code>```

Don't know JavaMail so can't tell you how, but you could do the same so that all mail sent by the system will show in Outlook (and probably in most other e-mail clients) as From X on behalf of Y.

Title: Should I use Legitimate Email spoofing?

Body:
Recently I receive a request: users' emails are stored in the database, and as request of a user, the system will send an email on their behalves.

To add more context, it's like sending an email from the vendor, to their customers' email addresses. But it's not a fixed email (it depends on which vendor ask the system).

Using JavaMail, I can simply set the from field. But something doesn't seem right. When searching for this kind of work, I come across "Email spoofing" - which looks like what I'm going to do. There are some drawbacks for this approach, such as it may make the emails attractive to the spam filters, and so on...

Ofcourse I can just do as the client want, but I just wonder, is there any better alternative?

Body:
Outlook knows when I sent mail from GMail using a different address than that of my GMail account. It shows them as From  on Behalf of . Outlook can only know this if GMail sends more headers than just the "From". And indeed it does. In the headers of an e-mail I sent in this manner, I can see:

Return-Path: GMail account
Sender: GMail account
From: Marjan Venema <other account>

Don't know JavaMail so can't tell you how, but you could do the same so that all mail sent by the system will show in Outlook (and probably in most other e-mail clients) as From X on behalf of Y.


答:
I think the largest reason was the success of graphical user interfaces like X and Windows. A GUI consists of several objects which have a behaviour on their own, something that OO is able to represent closely.

On the other hand, a text-based user interface (that doesn't try to resemble a GUI) often simply follows a command-response pattern, which can be easily implemented in a procedural language. Business rules and similar stuff has been implemented with procedural languages for decades, without too many problems, and still today many OO programs for business applications are rather procedural; with stupid objects that hold the data and stateless objects that contain the business rules; the first could be records in a procedural langauge, the later could be, well, procedures.


答:
Aside from programming language syntax, the word class is not a good name from data modeling perspective in the case of a school information system. When you think about what a class means you find that (among other things):

A class is an regularly scheduled activity that has a start and end and is supervised (taught) by a school educator. Within this activity a subject is taught or an activity (like sport) is performed, so, a subject is offered as zero, one or more classes.

So the word class is really a "Scheduled Educational Activity" So you have the choic of:

ScheduledEducationalActivity

ScheduledActivity (in which case you can be more generic and allow the activity to be educational or an event like a lecture or a seminar or a tournment,...etc.)

SubjectOffering

So the name class really is a convention or (a business name) but is not the best name that describes the entity.

Title: A Class named Class?


答:
In the beginning there was imperative programming (if you could call it that). Simple instructions that told the mainframe what and how it should be calculating. Those programming languages used unconditional jumps and other "unstructured" instructions, most of them exotic by today's standards.

Then somebody came up with structures for programming. The for, while, do while and foreach we know today. It was a big innovation since now applications with relatively complex flow could be written and understood easily. Thus structured programming was born.

Then came some other folks who said that you needed to repeat a lot of code here and there and it was a nightmare to maintain so a way of reusing code should be invented. People came up with procedures and functions to delimit reusable bits of code. This also gave birth to the encapsulation and single responsibility principles.

Then some academics said that functionality should be closely coupled with the data it is working on. Then they added the concepts of inheritance for code reuse and polymorphism to match the logical way classification worked in real life. Thus the third generation programming languages and OOP was born.


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

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

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

What would you do?

答:
Personally I don't see the reason of banning Messenger and a other messaging services (including twitter), cause it's a way of getting information as fast as possible and sometimes people have great networks they can leverage in that way. What I do understand is why people ban facebook at the office, cause I don't see it as a way of keeping professional contacts (and many have gaming tendencies aswell).

With that set look at the year...2010 that means the age of smartphone so if I really wanted to used facebook I could do it on my phone without the company being able to track it unless they see me sitting with my phone constantly and that would just be to obvious what I was doing.


答:
Many companies forbid their programmers from using Open Source as they perceive it to be just some hacked together code that that they cannot have supported by a company.

While there is some truth in that (most/many not officially supported via paying for incidents etc), many open source projects are better supported by their great networks of builders/users and needless to say can be customised by you yourself if need be.

Some people like the comfort blanket of having paid for something and assuming/getting guaranteed support.

Title: The overlap between open source and closed source

Body:
I would like to understand why do some people like open source and some others like closed source? Let me be more specific and make my question about web development. If I build my site using an open source server side language what are the benefits for me? and if I build it using a closed source server side language, what are benefits?

I just want to understand how can I choose between the two differnt paradigms when building different types of web sites and applications!


问:
Is Rule 9 of Object Calisthenics applicable in Objective C?
Rule 9 in Object Calisthenics by Jeff Bay (RTF) is:

Rule 9: No getters/setters/properties

The last sentence of the previous rule leads almost directly to this rule. If your objects are now encapsulating the appropriate set of instance variables but the design is still awkward, it is time to examine some more direct violations of encapsulation. The behavior will not follow the instance variable if it can simply ask for the value in its current location. The idea behind strong encapsulation boundaries is to force programmers working on the code after you leave it to look for and place behavior into a single place in the object model. This has many beneficial downstream effects, such as a dramatic reduction in duplication errors and a better localization of changes to implement new features.

Another way this rule is commonly stated is “Tell, don’t ask”.

I get the point of the rule. But I find it only useful in garbage collected environments where modifying a reference is very simple.

Will this be of any help in Objective C? Because it's always important to let only setter change the ivar and let it also take care of retaining new value and releasing the old one. and use the setter anywhere inside methods to alter ivars which are pointers.

答:
I think this rule is about public getters/setters/properties.

It's OK to let objective-c properties handle retaining/releasing providing that you don't make them public. You can use categories to make properties private.

That way you have the best of both worlds:

you don't break encapsulation

you manage memory properly and easily


答:
Initial Cost has a role to play. Open Source is generally cheaper on both the hosting and the tooling. The only way that closed source competes is by trying to provide better tools, sometimes even free tools. If your input costs are low open source can be an excellent option.

Microsoft will give away the web developer version of Visual Studio to bait developers in, and then give them a beautifully functional environment that makes development easy. They hype everything up and keep new features rolling in.

Consider portability VS level of integration.
Open Source can be very sustainable, because you can change out parts you don't like or parts that fall out of favour. With Closed source you are stuck.

Generally speaking Closed Source solutions are more tool focused and more integrated. Open source does not enforce use of any  specific tools and represents a mix-in manner of solving problems.

The level integration in closed source can be high. For instance Microsoft provides

The programming language (c#)

The framework (Asp .Net)

The Database (Sql Server)

The Web Server (IIS)

The OS (Windows)

With open source you can have any combination of operating systems, DBMS, framework and language. They are not tightly integrated, but they are portable.

Consider customizability . Closed source systems are not very customizable. They try to provide pluggable frameworks etc but mostly there are points where you get stuck. Sometimes they have a premium product that you then have to invest in.

Consider giant applications that need custom caching, database solutions, or even a customized OS to run. If you reach that point that your application is so massive that no prebuilt solution can deal, and you want to customise, open source will pay off.


问:
Custom search engine
I have made a web application and now I would like to add a search option to it.
Since it is a learning project, I can't afford to buy some Google license. That is why I consider creating my own search engine.

From what I have read, there are two major ways to do it: using Apache Lucene or using Apache Solr. I have read a bit about both, but I really don't understand what is the difference between them. Which one should I choose?

I am looking for something free which is easy to learn and use, so you have other suggestions please let me know.

答:
Lucene is a search engine and Solr is a search application.
With search engine you have to create everything from scratch, with search application you have everything out of the box.

Lucene is more shared-hosting friendly.
You can create a basic search engine (without scoring, faceted search, etc) in an hour or two.

If your hosting provider allows you to install Solr, go for it.
Otherwise Lucene should be just fine.

Solr is built on top of Lucene so everything you can do with Solr can be done with Lucene and few extra lines of code.

Title: Custom search engine


答:
Solr is the search platform which internally uses lucene API.

according to your requirement ,you may go for Solr

in 2010 both are merged.

Title: Custom search engine

Body:
I have made a web application and now I would like to add a search option to it.
Since it is a learning project, I can't afford to buy some Google license. That is why I consider creating my own search engine.

From what I have read, there are two major ways to do it: using Apache Lucene or using Apache Solr. I have read a bit about both, but I really don't understand what is the difference between them. Which one should I choose?

I am looking for something free which is easy to learn and use, so you have other suggestions please let me know.


问:
Software requirements analysis or requirements engineering?
I've been looking around for some articles regarding to requirements analysis, but I'm a bit confused with the term, because based on Wikipedia requirements analysis is a stage of requirements engineering. </p>

<p>But once you search more, many of the websites use them interchangeably as in they mean the same, can you please help me clarify this? </p>

答:
Requirements engineering sounds like a more formal process with a number of stages.

Requirements analysis, to me is the specific task of getting/figuring out requirements.

As such, I wouldn't consider them interchangeable.


答:
Essentially speaking, Requirements Analysis is a subset of Requirements Engineering. Very often you come across a client or a scenario where the requirements are not clear or pre-determined and this is where you have to engineer (determine, analyse and design) the requirements and show them to the client to validate (according to their budget).

In order to conduct Requirements Engineering, it is almost essential to know UML and other modeling tools that assist in comprehending, understanding and designing the system.

Title: Software requirements analysis or requirements engineering?

Body:
I've been looking around for some articles regarding to requirements analysis, but I'm a bit confused with the term, because based on Wikipedia requirements analysis is a stage of requirements engineering. </p>

<p>But once you search more, many of the websites use them interchangeably as in they mean the same, can you please help me clarify this? </p>


答:
Requirements engineering is a term that includes all activities related to requirements - elicitation, analysis, documentation and specification, validation, and management. It might also involve some levels of modeling, ranging from the creation of use case models to more detailed collaboration with system architects and designers.

Requirements analysis is one aspect of requirements engineering that involves reviewing the requirements to ensure that all requirements are useful to building the product. For each requirement, the person or people performing the analysis will ensure they have the characteristics of a good requirement. Some source also consider early prototypes to be part of requirements analysis, since it helps to further understand and clarify requirements given by stakeholders or identify problems with the requirements.

To think of requirements engineering as a staged activity, however, it probably not a good idea. The various activities are ongoing throughout a requirements definition phase of the project. With some regards, requirements engineering also happens throughout the entire project. It just becomes useful to give names to activities to make it easier to discuss with others.


答:
Finding a synonym is a good idea, e.g "Course."

However, the need to reuse the word class is common (often for a local variable of type Class), and the conventional replacements for class  include klass, clazz,  and cls.

Title: A Class named Class?


答:
In some programming languages you can use reserved words in the variable names (possibly even class names?). For example in C# you could do like this even though class is a reserved word:

```<code>string @class = "Super class";
</code>```

You could check your programming language specs does it allow you to do this.

If not then just go with Winston Ewerth's answer.

Title: A Class named Class?

Body:
In some programming languages you can use reserved words in the variable names (possibly even class names?). For example in C# you could do like this even though class is a reserved word:

string @class = "Super class";

You could check your programming language specs does it allow you to do this.

If not then just go with Winston Ewerth's answer.


问:
How to check or assess debugging skills of a person?
What kind of skills determine a person that is capable of debugging code with ease? Some time ago my friend carried out an interview with a relatively good programmer. The programmer got hired. He could write good code, understood the frameworks and design patterns. The thing he was missing was - debugging skills. He could not debug at all and finding problems with his or someone else's code was huge pain for him.

Since then we are thinking about how we can assess or estimate a person's debugging skills.

So the first question is: what skills determine if a person can effectively debug software?

And the second: how to test those skills during the interview?

答: Sit them down at a computer with some simple binary (with debug) symbols that segfaults with null pointer reference or such + source code + gdb and see if they can find the cause of the crash?</p>


答:
Usually people with good aptitude are also the one with good debugging skills.

During the interview, (depending on their seniority) you can give them an assignment of the like of puzzle such as some algorithm or so. That's the simple way.

If you can, you can print a code out of some work ask the person if something is wrong here and if so how to fix it.

I don't quite prefer to ask obfuscated interview questions which tends to focus on people's ability to read and fix syntax.

Title: How to check or assess debugging skills of a person?

Body:
What kind of skills determine a person that is capable of debugging code with ease? Some time ago my friend carried out an interview with a relatively good programmer. The programmer got hired. He could write good code, understood the frameworks and design patterns. The thing he was missing was - debugging skills. He could not debug at all and finding problems with his or someone else's code was huge pain for him.

Since then we are thinking about how we can assess or estimate a person's debugging skills.

So the first question is: what skills determine if a person can effectively debug software?

And the second: how to test those skills during the interview?


问:
Communications regarding maintainability of code
I'm in search of good language or metaphors to discuss the maintainability of code with non-technical folks (PMs, business sponsors &c).

In particular, I've recently created a few one-off, get-it-done-tonight, gets-the-job-done pieces of code. Everyone, including the internal sponsor, knew that we were saving a couple hours based on the premise that the code would be used once, for the immediate need, and not again.

Then the inevitable: "Hey, remember that thing we did? Let's do it again, but with these minor changes." Of course, the minor changes aren't so minor, all the more so because the code was written as a big ol' procedural nastiness hinging on assumptions about the environment. [Yes, yes, I know, avoid the problem in the first place. Don't write bad code. Write everything as if it will be maintained by someone else, or me years from now. That's a different question, though. This is after it's happened.]

So what are some good metaphors for the internal sponsor (non-technical) to quickly explain why the code isn't maintenance or minor-change friendly?  The walls on a movie set: There's no garage there, it's just a door. -or- The doors are welded shut on this car.

How do you describe this continuum?

I want to find some terms for our group that will help talk about how much effort goes in up front and how that will improve maintainability: illustrating the trade-offs in "Do you want this tonight or do you want it maintainable?"

(In writing this up, I realize this might be the same as defining 'maintainable' for non-technical stakeholders. Seems like explaining loose coupling to non-technical types may not be the best way out of this. If you've successfully done that, how?)

Edited for answer:
For now I will continue to use building construction metaphors. This will turn into the size and strength of the foundation: "Yes we can build that building on this, but we will need to rework the foundation to be larger and cover the right area."

答:
Think of everyday objects with well-defined interfaces that make it easily replaceable, like a light bulb or battery.  Explain that the very first electric lights Edison built didn't have nice screw-in bulbs, because it was faster just to wire the bulb directly when designing it than to spend extra time designing a screw-in socket.  Sockets were developed later when bulbs had to be replaced frequently.

Software's the same.  There are ways to "directly wire" some things in that make it faster up front to develop, but also make it harder to replace parts of it.  If you want to make a lot of changes later on, first you have to design the "screw-in socket," then the rest will be quicker and easier to change.


答: I'd say distill a bug that you had in your system to something that can be discussed in the context of an interview. Fire up the debugger and let him at it.</p>


问:
Getting to the big leagues & managing time as a novice game developer?
I'm a 23-year-old novice game developer who just got his first job in the industry a year ago. Unlike most programmers I know, I started programming pretty late, during my second year in college, and I didn't work on any projects of my own until a couple of months ago. I feel like I'm doing quite well and picking things up quickly, but what intimidates me the most is just how many "prodigies" there are in the industry. If you read the biographies of any set of randomly-picked indie developers, you'll almost certainly find that they started programming at the age of 8, that they made 20 games before starting their latest successful venture, that they got together with a group of friends to start a company straight out of college, that they do music and art in addition to programming, etc. Especially now that I no longer have the free time afforded by a lack of responsibilities, I'm starting to get scared that I'm running out of time.

So my question is this: how important, really, is this time differential? Does it actually take 10 years to "catch up" to a developer who's been programming since they were a kid, or does that difference matter less when you're programming professionally? And more generally, if you're less experienced than your peers, how on earth do you juggle expanding your technical knowledge, networking with fellow developers, working on side projects, planning a business, maintaining a social life, and retaining a job while at the same time not dying of exhaustion?

Apologies if this isn't a good question — I'll delete if I see downvotes.

答:
If you read the biographies of any set of randomly-picked indie
  developers, you'll almost certainly find that they started programming
  at the age of 8, that they made 20 games before starting their latest
  successful venture, that they got together with a group of friends to
  start a company straight out of college, that they do music and art in
  addition to programming, etc.

This is called marketing.. The purpose of the bio is to self-promote and promote great talent within the firm. They have a 2 inch layer of sugar coating the surface.

Does it actually take 10 years to "catch up" to a developer who's been programming since they were a kid, or does that difference matter less when you're programming professionally

The market does not care about code you write as a kid, it cares about professional accomplishments*. What made these guys great is not the they coded as kids, but their great interest in the subject matter and the drive to succeed and be great at what they do. (Think Jobs and Woz: Woz had the talent and great interest, Jobs had the drive and perfectionism.)

You have a job working with good people in an industry you love, learn from the people around you. You will advance in no time.... That being said, you need to set better goals for your self. Bench-marking yourself to others is not a goal in and of its self, but is a useful tool to to help you set goals for yourself.

*"I wrote an iPhone app that sold 150 copies" is a lot more respected in the market than "I wrote 20 iPhone apps for fun & learning". One professional failure outweighs 20 amateur side projects. The fact that you took it to market speaks volumes.


答: If you have your candidates do a preliminary code tests, ask them to modify the code during the interview to either solve a bug or add a new feature or better yet both.  If you make the code test specifications fairly vague, that would make it easier to create test cases with "bugs" in then.</p>


答:
I am agree with @Winston Ewert that I'd pick another term because the word Class can be ambiguous.

In this case you have to use better synonym that suit your implementation. If i do model the such type of architecture then i shall go for Course, but there are other synonym also available can be used..

Check a example class architecture that somewhat match to your system. Ref:

As your question tagged with the naming, use a noun or noun phrase to name a class from synonym that you use.

Title: A Class named Class?


答:
I would argue that the best measure of a good software developer in a particular language or framework is the ability to critically analyze complex problems and to have good debugging skills in the language or framework.  They must be able to demonstrate low level debugging as well as proficiency in high level debugging with common debugging tools.

This means creating a scenario for them that demonstrates high aptitude of debugging tools in their chosen IDE.  You should look for things like:

Running sandboxed application or server in debug mode or building application with symbols for debugging

Making available and demonstrating remote debugging ports or debugging of non-sandboxed application that was built with symbols (if applicable to language)

Strategic use of breakpoints

Custom properties of breakpoints, conditional expressions on breakpoints (if applicable to language)

Use of expressions or variable watches for monitoring variable values or references

Use of ad-hoc variable value or reference or pointer manipulation in real time

Demonstrate ability to step into, over and out of application flow

Critical evaluation of call stack

Debugging multi-threaded applications and comprehending this.

Other debugging strategies without tools should be demonstrated as well, such as analyzing logs and source code, as well as ability to perform some low level debugging without the use of an IDE as well.


答:
If you want to see if a programmer can debug, give them code to fix. It's the same approach if you want to see if they can write code. Give them a problem and have them write code.

Now, I'm confused about this programmer who has no problems writing code but fails misserably when asked to debug. Does this person regurgitate code examples or just sticks to areas he has experience like reading and writing to a database? Unless they get the code right the first time, they can't fix it?

Maybe the person just doesn't like debugging and makes no effort? I'm no good at this so stop asking me to do it - learned helplessness.

Working on an existing code base requires looking through code, documention and possibly making some notes and desgins of your own.

I know we think of debugging as fixing production code that has failed, but I need to debug code while I'm writing it. Either this person isn't a very good programmer or they just prefer to write new code. Don't we all.


答:
In the same way you would determine someone's coding ability, ask them questions about debugging.

Ask them "how" they would track down a bug in a given situation.

Take it a step further and sit them down in front of a computer and watch them debug an issue.


问:
Is it bad practice for a decorator to break the decoration chain?
I'm currently using decorators to apply various modifications to a template prior to rendering it.

I'm unsure about my cache decorator, though, because it is currently able to break the chain of decorators and return a cached object as opposed to the original decorated object.

```<code>class Cache : Decorator
{
    public String Render()
    {
        if(templateCache.IsCached('some_template_identifier'))
        {
            return templateCache.Get('some_template_identifier');
        }
        String renderedTemplate = Template.Render();
        templateCache.Cache(renderedTemplate);
        return renderedTemplate;
    }
}
</code>```

Is this bad practice? Should I always be returning the original decorated object or is it ok to break the flow like this and return a different object?

答:
No, I don't believe that a decorator should ever break the chain. Essentially, if your Decorator doesn't decorate, then it isn't a Decorator. *8')

As it is, I'm not sure what behaviour you were expecting a cached decorator to exhibit. I would suggest that a Cached Decorator should cache the decorations to an object, and not a decorated object itself.

That way, when you wrap an object in your cached decorator, it decorates the object with the same set of decorations that your template object has/had.


答:
If the first thing the person wants to do is look at the code and step through it with a debugger that person is not a great troubleshooter.

If you don't already have a plan of action and you dive into the debugger blind you are basically Easter Egging. This is true for ANY kind of troubleshooting.

In an interview situation a person that asks how the system operates and asks about history of the system would be somebody that might be a good troubleshooter. A person that thinks system first and mechanics second could be a good troubleshooter.

This is true of any complex system.


答:
The technology changes so fast, 90% of what you knew about programming 10 years ago is completely worthless today.  For the most part, worrying about being behind is just silly.

Some knowledge does stick around.  Knowing that a multiply takes a lot longer than an add.  Knowing what binary trees and hash tables are and how to use them.  Being able to spot a real new idea (OOP, for instance) and hype (OLE, TQM).  But 10 years isn't enough to really pick up this stuff, and a 23 year old will learn it a lot faster than an 8-year-old anyway.  There's a few old-timers out there you're never going to catch, but we're not going to live forever.

And most of those prodigies aren't programmers, they're businessmen, managers, and even leaders.  And, most of all, salesmen.  Some of them are really great people doing really great stuff, but they hire programmers, they don't do the work themselves.  At least, not for long.

Title: Getting to the big leagues & managing time as a novice game developer?

Body:
I'm a 23-year-old novice game developer who just got his first job in the industry a year ago. Unlike most programmers I know, I started programming pretty late, during my second year in college, and I didn't work on any projects of my own until a couple of months ago. I feel like I'm doing quite well and picking things up quickly, but what intimidates me the most is just how many "prodigies" there are in the industry. If you read the biographies of any set of randomly-picked indie developers, you'll almost certainly find that they started programming at the age of 8, that they made 20 games before starting their latest successful venture, that they got together with a group of friends to start a company straight out of college, that they do music and art in addition to programming, etc. Especially now that I no longer have the free time afforded by a lack of responsibilities, I'm starting to get scared that I'm running out of time.

So my question is this: how important, really, is this time differential? Does it actually take 10 years to "catch up" to a developer who's been programming since they were a kid, or does that difference matter less when you're programming professionally? And more generally, if you're less experienced than your peers, how on earth do you juggle expanding your technical knowledge, networking with fellow developers, working on side projects, planning a business, maintaining a social life, and retaining a job while at the same time not dying of exhaustion?

Apologies if this isn't a good question — I'll delete if I see downvotes.


答:
I assume, what you meant when you said "Breaking the decorator chain" = "You are discarding the object which is passed to "class Cache" and returning your own

Which is technically incorrect to do and should be avoided, because

1) Decorator is a structural pattern, which changes the structure dynamically. Caching is not the same purpose as a decorator, do you see the fundamental issue here?

2) Decorator adds/modify something to the seed object passed to it before returning it, by doing cache you are not adding any thing to it

How to solve this then? options are
1 - Make sure the object is taken from cache before calling the decorator chain and enforce it by putting it in you data retrieval method

2 - Have one more level of inheritance (though i do not recommend) before all these decorators, in which you all ways try to get the object from the cache, before calling a virtual method of the derived decorator's method to Render()

that is my 2 cents

~Basav

Title: Is it bad practice for a decorator to break the decoration chain?

Body:
I'm currently using decorators to apply various modifications to a template prior to rendering it.

I'm unsure about my cache decorator, though, because it is currently able to break the chain of decorators and return a cached object as opposed to the original decorated object.

```<code>class Cache : Decorator
{
    public String Render()
    {
        if(templateCache.IsCached('some_template_identifier'))
        {
            return templateCache.Get('some_template_identifier');
        }
        String renderedTemplate = Template.Render();
        templateCache.Cache(renderedTemplate);
        return renderedTemplate;
    }
}
</code>```

Is this bad practice? Should I always be returning the original decorated object or is it ok to break the flow like this and return a different object?


答:
Ask him questions like this:

How do you tackle a problem?

What is one of the complex project that you did and how did you achieve it?

Which debugging tools did you use?

Do you have any preference for certain tools?

Give an example of your own scenario and ask him how he will tackle it?

How would you rate your ability to get into someone else code?

You can address your concerns by asking questions. There is always a risk he may or may not be good in certain skills. But if he is a good learner, that will help a lot.


问:
Is there an easy way to map directory structure to a MongoDB schema?
I'm trying to store a directory structure, including files and their content, in MongoDB. The work is part of a synching app, and is using in Node/Mongoose.

Now, I'm new to Mongo, and it's late here - is the idiomatic implementation as easy as it looks - ie, something like this?

```<code>var FileStoreSchema = new Schema({
  fullPath: {
    type: String,
    index: { unique: true }
  },
  filename: String,
  [Metadata and other useful fields]
});
</code>```

答:
It depends largely on what operations you want to be able to efficiently support. Your current approach will make it easy to list all files within a directory and all descendants of a directory.

On the other hand moving files from one directory to another is more painful because there is no atomic modifier that allows you to modify a substring of a field. Instead, you'll have to pull down all of the file entries, modify them, then push them back as updates. (Someone correct me if I'm wrong about this)

With this structure it is also relatively difficult to list out the directory structure for traversal. The only way to know every folder is to load every file path and then parse them to see if they contain a new folder.

Does any of this matter? Maybe not, depends completely on what you are trying to do.

As another possible method, do you really want to represent one hierarchy? Or do you get a better representation have many smaller hierarchies? If the second, then you may get better results storing each hierarchy as a complete document, representing folder structure with the nesting of documents or via parent-child references.


问:
Why is subclassing too much bad (and hence why should we use prototypes to do away with it)?
I was reading up on design patterns, and I read that the prototype design pattern does away with excessive subclassing.

Why is subclassing bad? What advantage would using a prototype bring about over subclassing?

答:
"Too much" is a judgement call.

As with most things in programming, sub-classing isn't inherently bad when it makes sense. When the model of your problem solution makes more sense as a hierarchy rather than a composition of parts, subclassing may be the preferred option.

That said, favoring composition over inheritance is a good rule of thumb.

When you subclass, testing can be more difficult (as radarbob noted). In a deep hierarchy, isolating problematic code is more difficult because instantiating a subclass requires bringing in the entire superclass hierarchy and a bunch of additional code. With a compositional approach, you can isolate and test each component of your aggregate object with unit tests, mock objects, etc.

Subclassing can also cause you to expose details of your implementation that you might not want to. This makes it difficult to control access to the underlying representation of your data and it ties you to a particular implementation of your backing model.

One example I can think of is java.util.Properties, which inherits from Hashtable. The Properties class is only intended to store String-String pairs (this is noted in the Javadocs). Because of inheritance, the put and putAll methods from Hashtable have been exposed to users of Properties. While the "right" way to store a property is with setProperty(), there is absolutely nothing preventing a user to call put() and passing in a String and Object.

Basically, the semantics of Properties are poorly defined because of the inheritance. Additionally, should anyone ever want to change the backing object for Properties, the impact will have a much greater impact on code that uses Properties than if Properties had taken a more compositional approach.


答:
The time differential is important, but only if:

you aim to be better than these people you compare yourself to,

your perception of success is only based on other people's success.

If you have fun doing it, who cares if others do it "better"?

As long as you (and possibly your family) are happy and can get by, seems to me like "you're winning".

Plus, your achievement over them will be exactly just that: you weren't a prodigy. You worked hard, you had to catch up, and you tried your best. Thinking that you HAVE TO catch up sounds like setting yourself for failure.

Though I don't mean you should be too easy on your goals either. It's great to aspire to be like the stars of your industry (speaking of achievements and skills, not necessarily of collaterals like lifestyle), it's good to push yourself. Just aim for what makes you happy and feel like you achieved something (and a bit beyond that), but don't aim for what makes others happy.


答: I've often given candidates hypothetical situations... for example, a production system has stopped responding.  What do you do?  They might answer "check the logs" and I say "the logs show nothing abnormal, except that there is nothing written in them since the problem started happening".  And so it continues, until I'm satisfied that I've assessed the candidates ability to problem solve.</p>


问:
Offshoring a Software Project -- Conflict Resolution
I had been tasked with managing a project which was outsourced to some Ukrainian developers.

The company hired them through Elance at a fixed price. At that point my boss left me alone to handle them and get the work done. I created a detailed specification of the complete thing that needed to be done.

The project involved dealing with such things as XMPP, RabbitMQ, and Database. In my first meeting with them (always IM) I explained thoroughly what they needed to do. They seemed to understand it -- and they were very confident that it would be done easily.

So far so good. But after one week, when we met again, they were full of misunderstandings about what needed to be done. When I asked one of the developers if he knew XMPP, he said he was working with it for the first time. At our first meeting I'd very specifically mentioned the complexity of the project and the technologies involved. Plus, I had repeatedly asked them to write a functional specification of exactly HOW they would do it. But they said NO, and insisted that they would rather write the code. I said OK.

The project completed after 3 weeks and they delivered what was needed. At that point I started to review the code. It was okay for the most part, but there ware some important problems:

they hard-coded some of the things that needed to be separated out into a config file

there were multiple config files that I needed to be consolidated in one

they wrote absolutely NO documentation

some other minor changes

I asked them to make these changes (except documentation) -- And, we had an argument.

They said, since the price was fixed, I was being unfair in asking them to make any changes once they completed the working code. That they had worked for unreasonable amount of time on the project and now it was completely wrong to ask for anything.

Finally now they have made the changes, and the project is over. But it leaves some  questions in my mind...

They did what was needed but I needed it properly done, and hence the changes. was I really unfair?

Why did I agree on letting them code without having a functional specification?

Why did I not make sure that they understood everything the first time?

Does anyone find themself in the same position? Do you think there is a better way to manage outsourced projects?

-- UPDATE --

Thanks for all the opinions -- after reflecting upon entire experience, I can conclude...

Although I wasn't vague in the specifications from my side, I certainly didn't make them ironclad as suggested. So the take away is: always be as much specific as possible -- read your specs from their perspective too and see if you missed something. Repeat it at least three times.

Just specifying what the code should do it not enough. You must specify what the code is supposed to look like. What the directory structure will be; even the file names if possible. This will save you from lot of annoyance later. Strictly specify the coding guidelines, variable naming conventions, internal documentation format, etc. See to it that they abide by those guidelines, and if not, scream.

Demand a functional specification from their side -- insist that it be written before any code. This will get a lot of confusions and misunderstandings out of the way.

Review the code as it is being developed so that you identify the anomalies earlier and get them corrected. Talk to them at least once every other day.

Lastly, try to make a good rapport with them. Make them feel that you appreciate their work. Don't push them exaggeratedly to fit your guidelines -- instead request them to do so and tell them that it would make maintaining the code so much easier for you once they complete the project.

答:
I needed it properly done

Then don't outsource it, or if you do then make sure they work in your project team and that you participate in code reviews at the time.

The project completed after 3 weeks and they delivered what was needed. At that point I started to review the code.

Again, you should have been reviewing code during the project, not after.

They said, since the price was fixed, I was being unfair in asking them to make any changes once they completed the working code.

You paid them fixed price for working code.  Oops.  That isn't their fault, its yours.  Pay for their time to participate in sprints that you control and you won't run into this problem.  You should pay them for the time and accepted user stories, not for code.

In my first meeting with them (always IM) I explained thoroughly what they needed to do. They seemed to understand it -- and they were very confident that it would be done easily.

When dealing with a completely outsourced project, you need to make sure your specifications are ironclad.  If you have to explain anything that takes longer than a few sentences, then your spec is not complete.  This is why they veered from the spec.

When I asked one of the developers if he knew XMPP, he said he was working with it for the first time.

It is common when outsourcing to popular low cost offshoring countries for developers to overinflate their resumes and skills just to land the job.  They often don't worry about their abilities until they land it, becuase many of them are just resume building to land the gig that actually pays a comfortable living wage.

Why did I agree on letting them code without having a functional specification?

Only you can answer this for yourself, but take it as a learning experience for next time.


问:
Algorithm for scheduling a set of real life tasks that are input by the user
I am trying to write some code to schedule a set of real life tasks that are input by the user. These tasks are stored in an SQLite database. And at the moment, the only parameters I am taking into consideration are the,

```<code>The project to which a task belongs to --> p
The name of the task itself --> t
And the due date for this task --> d
</code>```

The project and due date parameters are optional. But assuming that the user will always input at least the task name and due date for every task.. I was wondering if it is possible to schedule the set of tasks using a scheduler like the Completely Fair Scheduler (CFS) for example. I realize that the CFS was written for scheduling tasks with much finer granularity (nanoseconds) than the set of tasks being proposed for this purpose... But I realized that it might be possible and maybe more efficient if I can modify it to work with tasks that are on the same time scale as our perception of time.

A typical entry in the database would be in the format (p, t, d). 'p' is optional. Here are a few examples:

```<code>(_, 'Call home', 29/2/2012)
(Work, 'Meet boss', 14/3/2012)
(Work, 'Ask for raise', 18/3/2012)
(_, 'Book tickets', 10/3/2012)
(Work, 'Quit', 14/4/2012)
(Personal, 'Get botox injections', 10/3/2012)
(Personal, 'Get breast implants', 10/10/2012)
(_, 'Dad bday', 7/10/2012)
</code>```

Here is a situation to consider. I would like to wake up in the morning. Run this "yet to be coded" algorithm on the set of tasks.. like the ones given above.. and I would like to receive a schedule for the rest of day, that maximizes throughput. At a later stage, I would like to pass arguments to this algorithms that would allow me to control the scheduler to return a set of tasks depending on my current situation. Like if I am at work, I want to be able to pass arguments to the algorithm, to ask it to only return tasks that can be completed at work..

I hope I am able to convey the gist of it. I understand that the due date alone is not sufficient to schedule tasks using the CFS for example... but if there are other parameters that I should consider, please do let me know. And any suggestions for the kind of scheduling algorithm to employ would be helpful.

答:
This is something I've long desired as well.  But a kernel scheduler only has to decide what task to run right now, not when in the future to run other tasks.  So those schedulers may help you with part of the problem, but there is a lot more here than they solve.  And they have a key bit of information you aren't keeping; namely if a task is blocked or not.  (Actually, the kernel is going to track process states, I'm over simplifying here.)  You're going to need to know what a task is blocking on so that the user can tell you if the task is unblocked.

If you want to be able to schedule out your day, you're going to have to include an estimate of the time remaining for a task.

You'll want to tie task dependencies into it as well.  And that's not even getting into scheduling things with external events like 'order book' -> 'wait for it to arrive' -> 'read book' prior to ordering the book.

I think you're going to find that the problem gets deep quickly, and that having a well-thought-through and always with you UI is going to be critical.


问:
Worst coding standard you've ever had to follow?
Have you ever had to work to coding standards that:

Greatly decreased your productivity?

Were originally included for good reasons but were kept long after the original concern became irrelevant?

Were in a list so long that it was impossible to remember them all?

Made you think the author was just trying to leave their mark rather than encouraging good coding practice?

You had no idea why they were included?

If so, what is your least favorite rule and why?

Some examples here

答:
Enforced XML comments on all non-private methods, constants, enums, and properties.

It led to some pretty cluttered code, especially since the end result was people either just hitting /// to create an empty comment stub for everything or installing GhostDoc and having it add auto-generated comments:

```<code>/// <summary>
/// Validations the handler.
/// </summary>
/// <param name="propertyName">The property name.</param>
public void ValidationHandler(string propertyName)
{
   // whatever
}
</code>```

[Edit] The reason I mention this as a ridiculous standard isn't because I think method comments are stupid but because the quality of these comments wasn't enforced in any way and resulted in just creating lots and lots of clutter in the code files. There are better ways of creating meaningful code docs than blind "must have a comment" build requirement.

Body:
Enforced XML comments on all non-private methods, constants, enums, and properties.

It led to some pretty cluttered code, especially since the end result was people either just hitting /// to create an empty comment stub for everything or installing GhostDoc and having it add auto-generated comments:

/// <summary>
/// Validations the handler.
/// </summary>
/// <param name="propertyName">The property name.</param>
public void ValidationHandler(string propertyName)
{
   // whatever
}

[Edit] The reason I mention this as a ridiculous standard isn't because I think method comments are stupid but because the quality of these comments wasn't enforced in any way and resulted in just creating lots and lots of clutter in the code files. There are better ways of creating meaningful code docs than blind "must have a comment" build requirement.


问:
Payments and open source core developers
I'm not sure if there's an established protocol for this (even if it's not an official one), but thought those most experienced with open source might want to share with us.

I'm aware that random patches submitted to open source projects are never paid. They may be indirectly funded by a client but they're never paid for by the open source project itself.

But how about core developers? I heard for example that drupal has some 800 core developers behind it. Core developers means that they work on drupal core itself and together they push the main releases, so they're very important to the project. Of course drupal is just an example, but in general, is there any established protocol in the open source world that defines whether the company behind the project is expected to pay them and do these core developers expect such payment?

Any facts or first hand experiences?

答:
As a particular example, a few of the core Squeak developers work for Teleplace. They hack on Squeak as part of their day job, so Teleplace gets the stuff they need, and then release the changes to the base Squeak image and virtual machine back to the larger Squeak community.

There are quite a few other companies that pay their employees, in part at least, to hack on Squeak.


问:
Change my way of thinking in preparation for functional programming
When switching to a functional style of programming after coming from procedural and OOP, what things do I need to know upfront about "this new way of thinking"?

How do you prepare yourself for diving in the FP world and get it first time around?

What are the basics to learn and set straight first?

答: You have put the cart before the horse.  You don't need to prepare.  Just pick a language that looks interesting, find some documentation, and try it.  If you get stuck, then stop and search for an answer.  As you progress, your way of thinking will change.</p>


答:
First off this is not an issue of off shoring, it’s a vendor management issue

Yes, you made ALOT of mistakes…

They did what was needed but I needed it properly done, and hence the
  changes. was I really unfair?

Yes, it is fair, If you wanted it done a certain way you should have said that before the price was agreed to, so  they can bid accordingly.

Why did I agree on letting them code without having a functional specification?
Because you didn’t want to PAY for the spec! Documentation is time consuming and expensive, should they just do it for free?

Why did I not make sure that they understood everything the first
  time?

They did understand. But on your fist meeting AFTER the contract was signed (and the fixed price agreed to) is when you EXPAINED IT! So the needed to cut cost (hours) where every they could.. Basically by only holding one meeting a week, not giving any  confutation options.

Here is how to do this next time… In Two phases…

Phase 1: Have them Gather the requirements, perform the systems analysis and  write the Technical Design and\or functional Spec (Or write it yourself). Agree on a price for this Phase. Be sure to explain there is no commitment on your part to give them the development phase. Be sure to include time for meeting in the price.

Phase 2: Have them bid on the developed based on the spec now that they (and you) have, and really know the effort is involved. Again be sure to include time for meetings in the price. Because to include a small optional budget for changes.

Edit: I want to add an additional point.. The vendor is also at fault here, part of there job is too help guide you with the project management, and let you know where there are short coming in the process.

Title: Offshoring a Software Project -- Conflict Resolution

Body:
I had been tasked with managing a project which was outsourced to some Ukrainian developers.

The company hired them through Elance at a fixed price. At that point my boss left me alone to handle them and get the work done. I created a detailed specification of the complete thing that needed to be done.

The project involved dealing with such things as XMPP, RabbitMQ, and Database. In my first meeting with them (always IM) I explained thoroughly what they needed to do. They seemed to understand it -- and they were very confident that it would be done easily.

So far so good. But after one week, when we met again, they were full of misunderstandings about what needed to be done. When I asked one of the developers if he knew XMPP, he said he was working with it for the first time. At our first meeting I'd very specifically mentioned the complexity of the project and the technologies involved. Plus, I had repeatedly asked them to write a functional specification of exactly HOW they would do it. But they said NO, and insisted that they would rather write the code. I said OK.

The project completed after 3 weeks and they delivered what was needed. At that point I started to review the code. It was okay for the most part, but there ware some important problems:

they hard-coded some of the things that needed to be separated out into a config file

there were multiple config files that I needed to be consolidated in one

they wrote absolutely NO documentation

some other minor changes

I asked them to make these changes (except documentation) -- And, we had an argument.

They said, since the price was fixed, I was being unfair in asking them to make any changes once they completed the working code. That they had worked for unreasonable amount of time on the project and now it was completely wrong to ask for anything.

Finally now they have made the changes, and the project is over. But it leaves some  questions in my mind...

They did what was needed but I needed it properly done, and hence the changes. was I really unfair?

Why did I agree on letting them code without having a functional specification?

Why did I not make sure that they understood everything the first time?

Does anyone find themself in the same position? Do you think there is a better way to manage outsourced projects?

-- UPDATE --

Thanks for all the opinions -- after reflecting upon entire experience, I can conclude...

Although I wasn't vague in the specifications from my side, I certainly didn't make them ironclad as suggested. So the take away is: always be as much specific as possible -- read your specs from their perspective too and see if you missed something. Repeat it at least three times.

Just specifying what the code should do it not enough. You must specify what the code is supposed to look like. What the directory structure will be; even the file names if possible. This will save you from lot of annoyance later. Strictly specify the coding guidelines, variable naming conventions, internal documentation format, etc. See to it that they abide by those guidelines, and if not, scream.

Demand a functional specification from their side -- insist that it be written before any code. This will get a lot of confusions and misunderstandings out of the way.

Review the code as it is being developed so that you identify the anomalies earlier and get them corrected. Talk to them at least once every other day.

Lastly, try to make a good rapport with them. Make them feel that you appreciate their work. Don't push them exaggeratedly to fit your guidelines -- instead request them to do so and tell them that it would make maintaining the code so much easier for you once they complete the project.


答:
I entirely agree with maple_shaft's answer.

You accepted the code and I assume wrote the check, then reviewed the code, you sort of did everything backwards.

Why did I agree on letting them code without having a functional
  specification?

Because you didn't write it into the contract.  Since you wanted the work done, you accepted their reasons, even though its the very thing that got you into trouble.

Why did I not make sure that they understood everything the first
  time?

You should have provided them a design you felt would have worked.  Then it wouldn't really matter if they didn't understand fully.  I mean you didn't pay them to do it so who is going to do it?  How is this code going to be maintained without any documentation and design specificiations.  The answer it likely won't be.

They said, since the price was fixed, I was being unfair in asking
  them to make any changes once they completed the working code.

You are lucky they made the changes you wanted.  They could have said: tough luck

Does anyone find themself in the same position? Do you think there is
  a better way to manage outsourced projects?

Of course other people are in your position otherwise, the entire "outsource" industry wouldn't be hurting, many companies are starting to realize having to pay ( or wait ) to do it 3 and 4 times is more expensive then doing it right once.

At least by doing it yourself you can check the status of the project daily.  If you are behind there are things you can do to control the damage, at least in theory.


答:
Finding "the bug" in a little code snippet is a very artificial situation. I suppose it might be helpful in the same way that puzzles and brain teasers are.

A more comprehensive approach would ask behavioral questions about how the candidate has performed debugging in the past citing specific incidents and then following-up with questions.

Someone who is good at trouble shooting will be able to talk about more than just the debug facilities in the IDE. What about... the bug-reporting tools, end-user interaction, reproducing the bug, logfile analysis, verification?

There is MUCH MORE to debugging than tracing through a block of code and any evaluation of someone's skill in debugging should refect that.


问:
WCF Data Services (OData) Vs ASP.NET Web API? Hypermedia?
I'm desiging a distributed application that will consist of REST services and a variety of clients (Silverlight, iOS, Windows Phone 7, etc).  I was ready to decide that I would implement my REST services using WCF Data Services (OData) but now the the MVC 4 Web API has made me question that decision.

What I liked about OData was the URI querying and hypermedia capabilities you get for free.  What I disliked was the verbosity of the OData payload; lots of unnecessary characters coming over the wire.

What I like about the Web API is that the payloads are much more concise and it has the URI querying capability of OData, however it seems to be lacking hypermedia (out of the box, at least).  My boss is also pushing for the Web API because "the powers that be at Microsoft are backing it and OData hasn't been getting traction."

So I have two questions:

1) Can anyone comment on the backing/traction of the Web API and OData?

2) Is the Web API expected to natively support hypermedia by release time or are there any off-the-shelf implementations or examples I should look into?

Thanks!

答:
Web API does odata. See Scott Guthrie's blog post. Specifically:

Query composition: Web API enables you to easily support querying via
  the OData URL conventions.  When you return a type of IQueryable
  from your Web API, the framework will automatically provide OData
  query support over it – making it easy to implement paging and
  sorting.

I'd also think that in many cases the same class could be the traditional WCF class and the Web API class, they are definitely not mutually exclusive.