问:
How can I determine how to charge for supporting SharePoint sites and SharePoint development?
I recently created a site in SharePoint and I need to setup a maintenance/support agreement for the site. In addition to the site, there are some custom modules that were developed that we monitor. What considerations should I be making when determining how much to charge for supporting the SharePoint site and any custom applications developed for the site?</p>

答:
This depends somewhat on your sites.

If all sites use the custom modules, then you should have one support rate that includes the maintenance of the custom module(s), and you should determine this rate based on how confident you are in the stability of the custom work.

You can either price the custom modules individually, as add-ons, pricing them each separately for each site that adds them, or you could bundle them.

If you have some sites that use the custom modules, and some that don't, it makes sense to have Rate A for plain sites and Rate B for plain sites + custom modules, either one by one, or as a bundle.

The hardest part is determining how to price the custom modules, since you want the people who use them to pay for them, but you may not want the accounting headache of pricing support rates for every single module separately, if there are a lot of custom modules.

If one module is complicated and large, it may require a larger support cost than a smaller module.


问:
How do you handle multiple users editing the same piece of data in a webapp?
There's a project I'm working on that is looking to produce a web application that will manage a task list between multiple users.  This is a master task list whose task items get distributed by an authorized user.  Each user has his/her own account to login and view the tasks they are assigned; it is possible for multiple users to have a single task in-common.

I am trying to leave details of the project out of this as I'm grappling more with the overall concept of how to handle the following situations, but if it helps, I'm using Java, EclipseLink, and GWT with RequestFactory implemented.  The database is PostgreSQL.

So the conceptual problems I am attempting to reconcile are the following:

If a single task that is common to multiple users changes in any way e.g. task completed, deleted, etc., the task list of all the users who have this task will be updated.  What design patterns are there that assist in implementing this function?

Some patterns I have looked at are Observer and Mediator - are there others that should be considered over these?

Say there are two users changing the same task at the same time.

First, should I allow that situation to happen or should I put a lock on it until one or the other person is done making changes?

Second, if I don't put a lock on it, how do I reconcile whose changes to accept?  This involves the situation in 1 because user 1 could submit the data and before user 2 receives the updated data, he/she may have gone ahead and submitted his/her's changes.

I am really looking for any guiding points, advice, or tips you can provide on how to properly sync data between multiple instances of this web app.  I would very much appreciate it!

答:
I think Whiteboard will be your pattern of choice for #1, you should post changes to tasks (or other shared data) in a common place, so all interested parties can see them and DTRT.

For #2, you need to look at optimistic locking.  Basically, you need to timestamp all your editable records with the last update time.  When you try to save the record, you first verify that the record in the database has the same last-updated timestamp as your record.  If not, then someone has updated the record and you now have to either get the updated record and inform the user that they need to enter their changes again, or you can try to merge the user's changes into the updated record (which usually turns out to be either simple or impossible).

ContentLicense: CC BY-SA 3.0

ContentLicense: CC BY-SA 4.0


问:
Why don't languages include implication as a logical operator?
It might be a strange question, but why there is no implication as a logical operator in many languages (Java, C, C++, Python Haskell - although as last one have user defined operators its trivial to add it)? I find logical implication much clearer to write (particularly in asserts or assert-like expressions) then negation with or:</p>

```<code>encrypt(buf, key, mode, iv = null) {
    assert (mode != ECB --> iv != null);
    assert (mode == ECB || iv != null);
    assert (implies(mode != ECB, iv != null)); // User-defined function
}
</code>```

答:
I believe the answer lies in the mathematical foundations. Implication is usually considered and defined as a derived, not elementary, operation of boolean algebras. Programming languages follow this convention.

This is Proposition I of Chapter II from George Boole's An Investigation of the Laws of Thought (1854):

All the operations of Language, as an instrument of reasoning, may be conducted by a system of signs composed of the following elements, viz.:

1st. Literal symbols, as x, y, &c., representing things as subjects of our conceptions.

2nd. Signs of operation, as +, −, ×, standing for those operations of the mind by which the conceptions of things are combined or resolved so as to form new conceptions involving the same elements.

3rd. The sign of identity, =.

And these symbols of Logic are in their use subject to definite laws, partly agreeing with and partly differing from the laws of the corresponding symbols in the science of Algebra.

Boole's sign + represents the same "operation of the mind" we today recognize as both the boolean ´or´ and the union of sets. Similarly the signs − and × correspond to our boolean negation, complement of a set, boolean ´and´ and intersection of sets.


问:
What should every programmer know about programming?
Please, stay on technical issues, avoid behavior, cultural, career or political issues.

答: Which language and environment is most suitable for the job. And it's isn't always your favourite.</p>

ContentLicense: CC BY-SA 2.5


问:
How to get a reference to a central AssetLoader in every Widget?
I'm working on a simple UI system for a game. The building blocks are Widget objects, which can contain each other. There are several sub classes of Widget, e.g. LabelWidget, ImageWidgetand ButtonWidget.

Since nesting is possible, a ButtonWidgetis really nothing but a container for a LabelWidget and an ImageWidget. I'm pretty happy with that.

The problem is: I now need to use an AssetLoader to load images, I cannot get them directly from the disk. There are multiple AssetLoader implementations, one for each platform the game runs on, and there is only one instance which is created early on. And it has state.

So now I need to pass an AssetLoader object into ImageWidget. And into ButtonWidget, since it contains an ImageWidget. And so on. I've updated the code and now I need to pass an asset loader into almost every widget, and I really don't like what I see.

I've investigated some code bases of UI frameworks I like, and noticed that Android has something similar: There is a Context object which is passed into every view, which can be used to load resources. But since views there are usually instantiated magically from XML, it's not as annoying to use as what I have.

I can think of only one way out: Make a singleton that does nothing but offer a reference to the asset loader, e.g. AssetLoaderHolder. But I'm not convinced that this isn't actually worse than what I have.

Can you think of any remotely elegant solution for this? Note that using a dependency injection framework is not an option for me.

答:
If all widgets have a reference to their container widget, implement a method to ask the container for the AssetLoader or Context if they don't have their own; then you can just set it on the top-level container widget and it'll be available to the whole hierarchy.

There are variations on how it could be implemented, but here's a simple version in Java:

```<code>public abstract class Widget {
    private Widget container;
    private AssetLoader assetLoader;

    protected AssetLoader getAssetLoader() {
        if (assetLoader == null) {
            return container.getAssetLoader();
        }
        return assetLoader;
    }
}

public class LabelWidget extends Widget {
    private String labelKey;

    public String getLabel() {
        getAssetLoader().getLabel(labelKey);
    }
}
</code>```

Body:
If all widgets have a reference to their container widget, implement a method to ask the container for the AssetLoader or Context if they don't have their own; then you can just set it on the top-level container widget and it'll be available to the whole hierarchy.

There are variations on how it could be implemented, but here's a simple version in Java:

public abstract class Widget {
    private Widget container;
    private AssetLoader assetLoader;

    protected AssetLoader getAssetLoader() {
        if (assetLoader == null) {
            return container.getAssetLoader();
        }
        return assetLoader;
    }
}

public class LabelWidget extends Widget {
    private String labelKey;

    public String getLabel() {
        getAssetLoader().getLabel(labelKey);
    }
}


问:
Java Logfile Parsing Assistance
I'm writing a log parser that continuously looks for specific patterns and then fires off events to another system when it finds these matches. The firing of the event is time critical to catch errors or ensuing problems. This part is non-negotiable in terms of design.

The log files belong to Applications and the Operating System; thus they can be rapid in logging, large in size and rotate based on time, or size.

What is a better approach to reading these log files, detecting when they change, and reading from their last read location as I wrote code to do this using a RandomAccessFile which kept the last read location for every file.

For dealing with large files and rapid logging I did this:

DataProducer - would get last read point in file and then find any
changes then add to a Queue

DataConsumer - any changes to the Queue
by way of size, would then cause this thread to wake and start
parsing all the items in the Queue for that log file. Deleting what
it has parsed.

I am looking for some suggestions (in light of what I have done) that may improve the current way I manage reading a file, and picking up when there are changes, and parsing the file efficiently (considering size and rotation). Code or an API will do.

答:
Sounds like a job for Splunk

You probably don't want to re-invent the wheel here. Splunk has a free option and can provide you a lot of extra useful functionality that you will probably need further down the road.

Title: Java Logfile Parsing Assistance


问:
terminology for upward devolution from modules to framework
Is there a word for the problem of a framework becoming married to the software modules it supports, for example adding methods to a base class that may apply only to certain subclasses or use cases? It's a particular kind of violation of separation of concerns.

The words that come to mind are "upward devolution" or "feature capture," but these seem to belong to politics, not engineering. Wikipedia has an article on "subsidiarity" which mentions politics and object-oriented programming in the same sentence, but I'm still not sure.

答:
What you describe sounds like an increase in coupling, so the framework and associated modules are becoming more tightly coupled to each other.

"Tight coupling" adequately captures all of the challenges / issues you're mentioning.


答:
I came up with a design for a desktop application (that has yet to be fully tested) with similar requirements that might be helpful.

My solution was to employ the MVC pattern (with a single Model but multiple Controllers and Views) where each Controller made changes to the Model using transactions (using STM) and when a transaction committed, the Model broadcasted an update notification to the View(s).

Each client also all kept track of anything being updated locally, but when those local updates were finished (i.e. sent to be committed) it reverted to using the underlying Model's info.

I also had an undo stack with all the changes the users made so that things could be reverted.

This might not be the best model for a web app though since the Model had to broadcast changes to the Views, which might not be the easiest w/ a web client.

Title: How do you handle multiple users editing the same piece of data in a webapp?

Body:
There's a project I'm working on that is looking to produce a web application that will manage a task list between multiple users.  This is a master task list whose task items get distributed by an authorized user.  Each user has his/her own account to login and view the tasks they are assigned; it is possible for multiple users to have a single task in-common.

I am trying to leave details of the project out of this as I'm grappling more with the overall concept of how to handle the following situations, but if it helps, I'm using Java, EclipseLink, and GWT with RequestFactory implemented.  The database is PostgreSQL.

So the conceptual problems I am attempting to reconcile are the following:

If a single task that is common to multiple users changes in any way e.g. task completed, deleted, etc., the task list of all the users who have this task will be updated.  What design patterns are there that assist in implementing this function?

Some patterns I have looked at are Observer and Mediator - are there others that should be considered over these?

Say there are two users changing the same task at the same time.

First, should I allow that situation to happen or should I put a lock on it until one or the other person is done making changes?

Second, if I don't put a lock on it, how do I reconcile whose changes to accept?  This involves the situation in 1 because user 1 could submit the data and before user 2 receives the updated data, he/she may have gone ahead and submitted his/her's changes.

I am really looking for any guiding points, advice, or tips you can provide on how to properly sync data between multiple instances of this web app.  I would very much appreciate it!


问:
Do I need to understand algorithms and data structures to be called a programmer?
It has been six years since I have been coding. Coding into all kinds of things like ActionScript, JavaScript, Java, PHP, Ajax, XML HTML, ASP, etc. I have used arrays, maps, linked lists, sets, etc and wherever I worked people like me. But whenever I am interviewed it is very likely that people ask me question on hashes, trees, stacks, and queues. Some questions are on juggling some sorting algorithms.  I don't know if I should really know them or should I stop calling myself a programmer. There is something in me which also tells me even if people who are asking all these questions select me, they will never be making me work of these things. Am I really required to know all this?</p>

答:
This might be an occasion where there can be a semantically-meaningful distinction between 'programmer' and 'software engineer.' In this context, specifically, we see that you have a knowledge of several programming languages and related technologies and that you can use them to produce desired results. This is a fine operational definition of 'computer programmer.'

I consider myself to be a software engineer. In most of the day-to-day aspects of my work, I probably do the same things that you do. I use computer language and related technologies to produce some desired result. However, I do have an understanding of data structures and algorithms, and I consider that knowledge to be a fundamental underpinning of my ability to do much more.

Often -- though not ever  day -- my job involves finding solution to complex problems for which there are no obvious solutions, nothing that is directly addressed by the features of the framework that I am using or the capabilities of the language that I am working with. In this, I need to analyze the problem and devise a solution and occasionally this process goes in the realm of large-scale architecture.

While an excellent understanding of these deeper issues is necessary to doing that kind of work, it is not sufficient. In other words, just knowing how a hash table works or why a heap sort usually has good performance characteristics isn't enough to be a systems architect or a senior engineer. It's the logical starting place, and from there you can start to dig deeper and travel more widely and gain the experience that is also necessary to tackle the larger issues.

I suppose that in order to answer your question, you should ask yourself, "What do I want to be? Where will I go with my career?" If you are content to continue doing what you are doing, then you might just want to learn enough data structures and algorithms to get through the largely arbitrary interview questions that you are faced with.

If you want to grow in your career and you have the passion for it that is essential, you should embrace these subjects as tightly as you can. If you have some time to work on them, an open mind and true enthusiasm, you'll find some wonderful and exciting things. I'll never forget the day that I first understood quicksort. The feeling of excitement and discovery set the course for much of the rest of my life, and I couldn't be more grateful for that. Now, I can't imagine doing anything besides working as a software engineer.

Best of luck with whatever you choose.


问:
My boss has a bad case of "Not Invented Here"
My department specializes in converting customer data into our database schema so that they can use our software.

Right now, we have C# applications that take an IDataReader (99% of the time it is a SqlDataReader), perform some cleaning and mapping, insert it into a DataRow object, and then use a SqlBulkCopy to insert it in to our database.

Sometimes (especially when the source database contains images as varbinary objects), this process can really bog down with a SQL transfer from the server to the app to just then turn right around and go back to the server.

I feel that if we re-wrote some of the conversions as SSIS packages it could speed things up a lot. However the biggest stonewall I keep running into is when my boss, in Not Invented Here fashion, pushes back and says "What if Microsoft drops support for SSIS? We will have all this obsolete code and we will be screwed."

This is not the first time that I have hit a "What if they remove that feature...?" answer from my boss. I don't have the time to write the conversion the old way, self-teach myself SSIS, and also write it the new way to demonstrate/test the benefits (None of us have used SSIS so there would be a period where we would have to learn how to use it).

What should I do in this situation? Stop pushing the new technology? Wait till he leaves the department (I am the 2nd most Sr. person in the department after him, but it could be years before he quits/retires)? Find a new way of getting him to stop being afraid of 3rd party tools?

答:
I feel that if we re-wrote some of the conversions as SSIS packages it could speed things up a lot. However the biggest stonewall I keep running into is when my boss, in Not Invented Here fashion, pushes back and says "What if Microsoft drops support for SSIS? We will have all this obsolete code and we will be screwed."

In my opinion, skepticism about SSIS is valid.

Seasoned developers hate black boxes, and there's a lot of magic that happens inside of an SSIS package.

Source control support for SSIS packages is sorely lacking. Diffing and merging SSIS dtsx files can be a nightmare if your dtsx packages aren't sufficiently modular.

By contrast, C# console applications are very transparent. You can always follow the code to figure out what's going wrong.

Also, consider that your boss is on the hook if anything goes wrong.

Therefore, he's entitled to have the overriding/only opinion on the matter.

I don't have the time to write the conversion the old way, self-teach myself SSIS, and also write it the new way to demonstrate/test the benefits (None of us have used SSIS so there would be a period where we would have to learn how to use it).

What should I do in this situation? Stop pushing the new technology? Wait till he leaves the department (I am the 2nd most Sr. person in the department after him, but it could be years before he quits/retires)? Find a new way of getting him to stop being afraid of 3rd party tools?

I recommend that you learn SSIS well enough so that you can demonstrate its benefits.

And if, after your self-study, you find that SSIS offers significant advantages over the more "traditional" approach, and you still can't convince your boss to change course, then I recommend that you find a different job in which you can use SSIS.


问:
How do you debug without an IDE?
Every time I look for an IDE (currently i'm tinkering with Go), I find a thread full of people recommending Vi, Emacs, Notepad++ etc.

I've never done any development outside of an IDE; I guess I've been spoiled. How do you debug without an IDE? Are you limited to just logging?

答: I don't understand why there is an aversion to debugging with the use of printf statements. There was a time when it took too long to recompile and link a program, but today it takes just seconds. I find it very easy to debug using cout, printf, qDebug(), etc. type of output. Printf statements give you a running history of everything the program did, that you can analyze after the fact, whereas running in the debugger causes you to have to manually remember the flow of the program as it runs. With printf's, you can convert the value of variables to specific units, display them in hex, decimal, whatever. The printf statements can list the names of the routines and variables, and line numbers as well. You can list only certain array elements depending on other variables. You can follow indirections. You can control the output very easily, put in counters, only print certain times through a loop, add and remove print statements as you debug, have different levels of debugging output, write to files, etc. It's much easier to see the history of your program written to a file than to try to remember all the places you stepped through manually, and maybe have to write down the contents of variables as they change through time, in order to discover what the program has done. And finally, with printf statements you can leave them in permanently, to be turned on and off, for future debugging.</p>

Title: How do you debug without an IDE?


答:
I'll take a crack at this from a managerial standpoint, but keep in mind that I'm aware I don't have all of the details. I'll summarize what I see:

Mid-level developer, we'll call him "Scott", recommends a rewrite of legacy code into SSIS to improve the performance of important process ProcessA.

ProcessA is currently behaving in a functioning state with no known major issues.

ProcessA is written with proprietary tools using common or potentially tribal knowledge to maintain.

Recommendation to rewrite will require new tools to support.

Current staff has no documented experience/knowledge with the new tools.

New tools are relatively recent replacements to older tools, and support for these tools may change reasonably within 4 business quarters.

From this perspective, all I see is a large outlay of money on the company's part to improve a process that isn't broken. From a technical standpoint I can see the appeal, but when you get right down to it, it just doesn't make business sense to make this change. If you had staff on hand with documented experience with SSIS and benchmarks to show massive improvement to this process (keep in mind, massive improvement MUST equate to $$$), the outcome might be a little different. As it stands now, though, I'd have to agree with management (somewhere a tree just died).

If you want to foster the adoption of SSIS and potentially lead into this refactor, you need to gain this experience and training with smaller, less important projects. Provide benchmarks and support for SSIS, and make sure that all of the infrastructure and support is in place before management will even consider making the change. Once you have the tool in use elsewhere, people on the team experienced with its usage, and a business "comfort" factor that support won't change and uproot everything, you will be more likely to sway someone to your viewpoint. Without those, you're barking up the wrong tree with that argument.

As stupid as it sounds, sometimes the "best" way isn't the best way.

Edit: In response to some updates to the question, I'll post a slight modification to my answer.

If the process is experiencing distress of some kind, rewriting it will still be a costly venture. You may want to consider what the cost of fine-tuning the existing code would be against rewriting the package. Consider the impacts not just to software but to any human interfacing processes. When attempting to get management buy-in to a rewrite, it still will always come down to the money. Unless you can show that the current distress is costing money now or will become large in the aggregate, management will still not see the benefit. This cost may not necessarily be financial in nature. If the slow down compromises a system causing downtime, introduces intrusion vectors, or some other "hard to quantify" symptom, you may need to find a way to translate that problem into a monetary risk equivalent. An intrusion vector, for instance, may lead to an intrusion which could result in lost, stolen, or corrupt data. The company could lose reputation or may fail a necessary security audit. The key is to get the manager in question to recognize the quantifiable benefits of the change.

Title: My boss has a bad case of "Not Invented Here"

Body:
My department specializes in converting customer data into our database schema so that they can use our software.

Right now, we have C# applications that take an IDataReader (99% of the time it is a SqlDataReader), perform some cleaning and mapping, insert it into a DataRow object, and then use a SqlBulkCopy to insert it in to our database.

Sometimes (especially when the source database contains images as varbinary objects), this process can really bog down with a SQL transfer from the server to the app to just then turn right around and go back to the server.

I feel that if we re-wrote some of the conversions as SSIS packages it could speed things up a lot. However the biggest stonewall I keep running into is when my boss, in Not Invented Here fashion, pushes back and says "What if Microsoft drops support for SSIS? We will have all this obsolete code and we will be screwed."

This is not the first time that I have hit a "What if they remove that feature...?" answer from my boss. I don't have the time to write the conversion the old way, self-teach myself SSIS, and also write it the new way to demonstrate/test the benefits (None of us have used SSIS so there would be a period where we would have to learn how to use it).

What should I do in this situation? Stop pushing the new technology? Wait till he leaves the department (I am the 2nd most Sr. person in the department after him, but it could be years before he quits/retires)? Find a new way of getting him to stop being afraid of 3rd party tools?


问:
Replacement for instanceof Java?
So I'm fairly new to programming in the real world (outside of academic projects) and have come across lots of posts saying that using instanceof is a bad thing to use to determine what class a specific object is.

My situation is that I have three classes, a base product class, one that extends off that and another that extends off that. These are all stored in the same table in a database and I have some code that needs to use the methods on each to pull data off them.

What is the best practice to get around this way of doing it? I have read some things about polymorphism but I can't find any examples that fix the issue I have. They all usually override a method which for me won't work as I need to pull different things from the different objects.

Is there a better way to do this or am I stuck with using instanceof or some sort of reflection to get the fields specific to the objects?

答:
You can use getClass() method.

Are you sure you need three different classes? Maybe one class with a switch inside will serve better?

Title: Replacement for instanceof Java?


答:
Try to see things from your boss' perspective.  It sounds like the functionality you're trying to replace is core to what your software does (cf. his "screwed" comment).  A good manager knows that you outsource your core business at your own peril.  He's rightly worried about betting the farm on some piece of tech that might disappear in the future.  When core functions are involved, Not Invented Here is actually a good thing.

If speed is a feature, you're going to have to find another way to speed things up.  Otherwise, if speed matters more to you than to your clients, I say drop it and forget about it.


答:
The reason instanceof is discouraged is that it's not OOP.

There should be no reason for the caller/user of an object to know which concrete class it is an instance of beyond which type the variable it is declared as.

If you need different behavior in subclasses add a method and implement them differently.

Title: Replacement for instanceof Java?

Body:
So I'm fairly new to programming in the real world (outside of academic projects) and have come across lots of posts saying that using instanceof is a bad thing to use to determine what class a specific object is.

My situation is that I have three classes, a base product class, one that extends off that and another that extends off that. These are all stored in the same table in a database and I have some code that needs to use the methods on each to pull data off them.

What is the best practice to get around this way of doing it? I have read some things about polymorphism but I can't find any examples that fix the issue I have. They all usually override a method which for me won't work as I need to pull different things from the different objects.

Is there a better way to do this or am I stuck with using instanceof or some sort of reflection to get the fields specific to the objects?


答:
I don't have the time to write the conversion the old way, self-teach myself SSIS, and also write it the new way to demonstrate/test the benefits (None of us have used SSIS so there would be a period where we would have to learn how to use it).

That's kind of the problem, isn't it? You're asking other people to risk their productivity on your idea, and you're not willing to go out on a limb to show them it's worth it. Technical leadership requires either risking your reputation or your free time to show that your ideas are worth having.


答:
I've tried SSIS to do simple tasks before.

It can be very annoying, since even simple tasks gives birth to low to mid-level complexity diagrams (no, there's no other way to "code" it except the diagrams). And the source control problems pointed by Jim's answer I wasn't aware.

Side problem:
So, for speed up, I suggest reduce the size of the transactions for your image bulks. Say, every 800 instead of 5000 rocords. It can reduce the size of the I/O needed to support that transaction.


答:
Typically when I find myself wanting to know the type of something it means I implemented my object structure wrong.  Most of these times it comes down to violating LSP.

There are times however where I wish I'd have a way to do dynamic dispatch and save a ton of boiler plate code and futureproof my object structure.  C# provides the dynamic keyword in the newer installments of the framework but as far as I know Java still does not have something similar.

That said, instanceof is generally better than comparing classes as it will support inheritence properly.  You can also use methods like isAssignableFrom and others from the reflexion API.  If you want to implement something like dynamic dispatch it can be done via the reflection API but beware, it will be slow.  Use with caution, ideally you should fix the object structure and desing of your app if you can.

Hope this helps

Title: Replacement for instanceof Java?


问:
How do you interview someone with more experience than you?
The company I'm working for is looking to hire a senior developer with more experience than me, and they expect me to do the technical part of the interview. I've only been programming a few years and am not sure I have the knowledge needed to evaluate the coding skills of someone who has greater understanding/experience than I do.

Can anyone recommend some technical interview questions to ask that are a good means for evaluating higher-level programming skills, but still be ones I can understand?

I would say I'm past the jr. programmer level, but nowhere near senior. Most of what I've done is built small apps (web and desktop), some of them fairly complicated, but all of them have been meant to be used by no more then a handful of users. I feel I have a decent understanding of most programming concepts and am capable of learning/teaching myself just about anything, however I lack experience. As my boss is fond of telling me, "You don't know what you don't know".

In particular, things we'd like the person we hire to have experience with (that I don't have) is: Multi-tier development, multi-user environment, large-scale application development, two-way messaging, shared sessions, and Multi-threading/BackgroundWorkers.

UPDATE:

In response to Thor's comment below, we hired someone a few months ago and I think it has been working out great. I am learning a lot, not just about coding but also about things like design patterns, software architecture, documentation, and how other larger programming teams get stuff done. Its not always easy having someone come in and point out better ways to do things you have done, but if you can swallow your pride and be willing to try out new things you can learn a lot.

The interview process went better than I expected. I started asking questions about things I was familiar with, then asked some questions about some things I was struggling with. Whenever the interviewee said something I didn't understand, I'd ask them to explain it to me and then write it down so I could look it up later on. Overall, I felt I was able to get a pretty good idea of the applicant's skill level, intelligence, and what they'd be like to work with.

答:
I like the Use your age as an advantage answer very much, and I would suggest something similar:

Use your lower level of experience as an advantage

This person is probably going to be your boss or mentor, so ask questions in a way that lets you find out if that person can actually mentor you.

Ask complicated questions that could be made a lot easier, or that include over-complicated problems. If he / she is any good, he / she will not only solve try to answer the question / solve the problem, but actually get to the real problem, showing you the flaws in your question. If he / she manages to do that in a polite way without intimidating you he / she is a keeper.


答:
Well, its all about the cost/benefit analysis.

What do you gain by rewriting it to SSIS? Speed? Does it matter? If its a process that get executed in a GUI and waste everyone time, then yeah, its probably a good idea to speed it up, because the money spent changing it will be gained back by more happy customer or internal employee doing their job instead of waiting for the software. But if its a night batch that start at 12am and it will end at 1am instead of 6am... there isn't much point. Yeah its 6 time faster but no one will feel the difference.

And your boss does have a good point. Microsoft do tend to abandon some of their technologies. VB6, Linq-to-SQL, ASP classic, COM+... This is a risk with any non-open source software (and open-source software that would be too big for your organization to maintain in case lack of update). If its central to your application, you should have a tight control over it.

Software is all about adding value to the customer, and technical improvement that don't yield much benefit while introducing risk don't really fulfil that role.


答:
instanceof isn't necessarily a bad thing, however it is something that one should look at.

An example of where it works correctly is in a place where one gets a collection of the base type and you only want the ones of a subtype.  Getting the network addresses from NetworkInterface.getNetworkInterfaces() returns back NetworkInterface objects which have a collection of InetAddress objects, some of which are Inet4Address and some are Inet6Address.  If one wants to filter the collection for Inet4Address objects, it is necessary to use instanceof.

In the situation that is being described in the original post, there is a Base class, something that extends that base class and something that extends the extended class.  While not completely informative, this seems to have the underpinnings of some less than ideal design.

When you are returning a base class unless there is good reason for it being designed that way (backwards compatibility between specifications of an earlier version) you shouldn't be trying to peek at the underlying types.  If you are returned a Set, you know you are getting a set.  It allows the developer to later change his or her mind to return a more specific type (SortedSet) or change the underlying type (HashSet to TreeSet) without breaking anything.

Reconsider your design of how the objects are structured and parented to see if one can make an better class model that is doesn't require a distinction of types.

Title: Replacement for instanceof Java?


答:
Good answers. If it ain't broke, don't fix it. I would only add

While the performance concerns might actually be true, that word "might" is a red flag. I would do performance diagnosis first, so I would have proof of what the performance problem was, before committing any resources to addressing it.

When considering the latest "solution" from Microsoft, one should consider that plenty of people have been burned by what MS were once touting but subsequently deprecated and then de-supported. If you want software to run for 10 or 20 years without major recoding, you should be very cautious of that. Our company has been badly hurt that way.


答: Turnover is going to be a consideration for your boss. SSIS is getting into the DBA arena compared to a programmer having that skill set. If your application doesn't use SSIS beyond the initial conversion, I'm not sure it makes sense to learn it and get new C# programmers up to speed because like your team, most don't have any experience with it.


答:
Develop a POC (Proof of Concept) and then demo it to your superior.  The POC should help you determine any real benefit with the technology you are proposing.  Then you and your superior can talk about the technology and develop pros and cons to implement it.

You will probably have to spend some extra time outside of normal work time to develop the POC.

As a side note from an SSIS point of view, I have used it and have developed SSIS packages.  We actually replaced a proprietary load process using SSIS packages.  We only did this because actual customers complained about the load times.  Load times decreased significantly with SSIS and everyone got happier.

SSIS is basically a drag and drop workflow with very little programming involved.  It does take some time to learn how the black box works, so you will need to take that under consideration if your team starts using it.


问:
Is there a design pattern to solve this problem?
I've been struggling with a design so I figured I'd ask here and see if anyone's able to help :)

High level overview

I'm designing an app to gamify exercise by creating mini competitions (ex. Who can lose the most weight in 3 months or bike the most miles in a month).

Users can create competitions (calling them races for now) and they need to be able to specify constraints - participants have to be in a certain age range, over a certain weight, maximum number of participants in a race, etc.

My Objects

RaceParticipant - for brevity, the only pertinent property is int Age.

Race:

```<code>public class Race
{
    public virtual int RaceId { get; set; }
    public virtual string RaceName { get; set; }
    public virtual int RaceTypeId { get; set; }
    public virtual TrainingType RaceType { get; set; }
    public virtual IEnumerable<RaceParticipant> RaceParticipants { get; set; }
    public virtual IEnumerable<RaceConstraint> RaceConstraints { get; set; }
}
</code>```

RaceConstraint abstract class:

```<code>public abstract class RaceConstraint
{
    public string DisplayText { get; set; }
    public string ValidationText { get; set; }
    public virtual bool PassesConstraint(Race race, RaceParticipant participant);
}
</code>```

RaceConstraint implementation MaxNumberOfParticipants:

```<code>public class MaxNumberOfParticipants : RaceConstraint
{
    public int MaximumNumberOfParticipants { get; set; }

    public MaxNumberOfParticipants()
    {
        DisplayText = "Maximum number of racers";
        ValidationText = "This race has reached the maximum number of racers.";
    }

    public override bool PassesConstraint(Race race, RaceParticipant participant)
    {
        bool result = false;
        if (race.RaceParticipants.Count() <= MaximumNumberOfParticipants)
        {
            result = true;
        }
        return result;
    }
}
</code>```

RaceConstraint implementation AgeRange:

```<code>public class AgeRange : RaceConstraint
{
    public int MinimumAge { get; set; }
    public int MaximumAge { get; set; }

    public AgeRange()
    {
        DisplayText = "Age range of racers";
        ValidationText = string.Format("Racers must be between the ages of {0} and {1}.", MinimumAge, MaximumAge);
    }

    public override bool PassesConstraint(Race race, RaceParticipant participant)
    {
        bool result = false;
        if (MinimumAge <= participant.Age && participant.Age <= MaximumAge)
        {
            result = true;
        }
        return result;
    }
}
</code>```

The question

My question is where to store MinimumAge, MaximumAge, and MaximumNumberOfParticipants.  I'm using Entity Framework code-first so I know I don't need to worry about the schema directly, but I do need to think about which properties to add to EF and which object they'll be connected to.

Currently EF would make a separate table for each implementation of RaceConstraint which seems like overkill and I definitely don't want DisplayText and ValidationText stored in the db for each instance.

I thought about moving MinimumAge, MaximumAge, and MaximumNumberOfParticipants to properties of Race because each race will have values for these, but that feels like Race and RaceConstraint would be too coupled.  I'd like to be able to add a RaceConstraint in the future as requirements change without having to add a property to Race and therefor add a column to the Race db table.

I think I'm going to have to make a container object for RaceConstraint that holds a collection of all possible RaceConstraints.  Would it make sense to put these properties in that object and then remove IEnumerable RaceConstraints from Race and instead add a property for the RaceConstraintContainer?

Or maybe I'm way over thinking this and there's a design pattern I can follow.  I'm sure I'm not the first person to come across this scenario!

Thanks in advance.

UPDATE

After mulling this over for a few days and trying out each of the answers, I think @maple_shaft really nailed the problem of EF getting in the way of OO design.  I think I found a compromise somewhere in the middle.  I added properties like MinimumAge, MaximumAge, and MaximumNumberOfParticipants to the Race object because from a database perspective, these are all very related and each race will have entries for each of these.

I changed the abstract class RaceConstraint to an interface that just requires bool PassesConstraint().  I made better use of DisplayText by making it a data annotation of the properties in race (ex. [Display(Name = "Maximum number of racers")]) since I really only wanted it for labels in the UI.  I moved the text from ValidationText to an exception message if a PassesConstraint() fails.

Finally, I made a RaceManager class to hold a List of RaceConstraints and handle adding users by checking each RaceConstraint.  This class will also handle removing users, determining winners, etc.

I think this will work well from an MVC standpoint too because I'm not passing models to the view that have methods.  The Race class will really just be there to hold EF data and will make for a clean model to use for adding or updating races from a view.

Thanks for the help everyone!

答:
It looks like you need to separate the Constraint metadata (DisplayText, ValidationText) from the values for each instance (MinimumAge, MaximumAge, etc.)

If the Display/Validation text isn't going to change unless you're making code updates anyway, I'd just declare them const and load them from a resource file.

MinimumAge, MaximumAge, age MaximumNumberOfParticipants should stay on the object where they have the most meaning and the least duplication.  It looks like the RaceConstraint subclasses are a good place.

FWIW, you are already using something very similar to the Specification pattern with the PassesConstraint method.


答:
I would implement a RangeConstraint with an indicator of the type if you're concerned about the database layout, this will give you one table for range constraints and an identifier (1=Age, 2=Weight, 3=IQ, etc), then the min and max is all you need otherwise. THen the PassesConstraint bit should just use a selector from a dictionary somewhere Dictionary<RangeConstraintType, Func<RaceParticipant, int>> rangeSelectors where you give it the constraint type, it returns a function that given a participant will give back the value to be validated against the range. Something like:

```<code>var _rangeSelectors = new Dictionary<RangeConstraintType, Func<RaceParticipant, int>>() {
    { RangeConstraintType.Age, (participant) => participant.Age },
    { RangeConstraintType.Weight, (participant) => participant.Weight },
    ...
};
</code>```

Then in your PassesConstraint it just..

```<code>public override bool PassesConstraint(Race race, RaceParticipant participant)
{
    var participantsMetric = _rangeSelectors[_rangeConstraintType](participant);
    return participantsMetric < maxValue && patricipantsMetric > minValue;
}
</code>```

Title: Is there a design pattern to solve this problem?

Body:
I've been struggling with a design so I figured I'd ask here and see if anyone's able to help :)

High level overview

I'm designing an app to gamify exercise by creating mini competitions (ex. Who can lose the most weight in 3 months or bike the most miles in a month).

Users can create competitions (calling them races for now) and they need to be able to specify constraints - participants have to be in a certain age range, over a certain weight, maximum number of participants in a race, etc.

My Objects

RaceParticipant - for brevity, the only pertinent property is int Age.

Race:

```<code>public class Race
{
    public virtual int RaceId { get; set; }
    public virtual string RaceName { get; set; }
    public virtual int RaceTypeId { get; set; }
    public virtual TrainingType RaceType { get; set; }
    public virtual IEnumerable<RaceParticipant> RaceParticipants { get; set; }
    public virtual IEnumerable<RaceConstraint> RaceConstraints { get; set; }
}
</code>```

RaceConstraint abstract class:

```<code>public abstract class RaceConstraint
{
    public string DisplayText { get; set; }
    public string ValidationText { get; set; }
    public virtual bool PassesConstraint(Race race, RaceParticipant participant);
}
</code>```

RaceConstraint implementation MaxNumberOfParticipants:

```<code>public class MaxNumberOfParticipants : RaceConstraint
{
    public int MaximumNumberOfParticipants { get; set; }

    public MaxNumberOfParticipants()
    {
        DisplayText = "Maximum number of racers";
        ValidationText = "This race has reached the maximum number of racers.";
    }

    public override bool PassesConstraint(Race race, RaceParticipant participant)
    {
        bool result = false;
        if (race.RaceParticipants.Count() <= MaximumNumberOfParticipants)
        {
            result = true;
        }
        return result;
    }
}
</code>```

RaceConstraint implementation AgeRange:

```<code>public class AgeRange : RaceConstraint
{
    public int MinimumAge { get; set; }
    public int MaximumAge { get; set; }

    public AgeRange()
    {
        DisplayText = "Age range of racers";
        ValidationText = string.Format("Racers must be between the ages of {0} and {1}.", MinimumAge, MaximumAge);
    }

    public override bool PassesConstraint(Race race, RaceParticipant participant)
    {
        bool result = false;
        if (MinimumAge <= participant.Age && participant.Age <= MaximumAge)
        {
            result = true;
        }
        return result;
    }
}
</code>```

The question

My question is where to store MinimumAge, MaximumAge, and MaximumNumberOfParticipants.  I'm using Entity Framework code-first so I know I don't need to worry about the schema directly, but I do need to think about which properties to add to EF and which object they'll be connected to.

Currently EF would make a separate table for each implementation of RaceConstraint which seems like overkill and I definitely don't want DisplayText and ValidationText stored in the db for each instance.

I thought about moving MinimumAge, MaximumAge, and MaximumNumberOfParticipants to properties of Race because each race will have values for these, but that feels like Race and RaceConstraint would be too coupled.  I'd like to be able to add a RaceConstraint in the future as requirements change without having to add a property to Race and therefor add a column to the Race db table.

I think I'm going to have to make a container object for RaceConstraint that holds a collection of all possible RaceConstraints.  Would it make sense to put these properties in that object and then remove IEnumerable RaceConstraints from Race and instead add a property for the RaceConstraintContainer?

Or maybe I'm way over thinking this and there's a design pattern I can follow.  I'm sure I'm not the first person to come across this scenario!

Thanks in advance.

UPDATE

After mulling this over for a few days and trying out each of the answers, I think @maple_shaft really nailed the problem of EF getting in the way of OO design.  I think I found a compromise somewhere in the middle.  I added properties like MinimumAge, MaximumAge, and MaximumNumberOfParticipants to the Race object because from a database perspective, these are all very related and each race will have entries for each of these.

I changed the abstract class RaceConstraint to an interface that just requires bool PassesConstraint().  I made better use of DisplayText by making it a data annotation of the properties in race (ex. [Display(Name = "Maximum number of racers")]) since I really only wanted it for labels in the UI.  I moved the text from ValidationText to an exception message if a PassesConstraint() fails.

Finally, I made a RaceManager class to hold a List of RaceConstraints and handle adding users by checking each RaceConstraint.  This class will also handle removing users, determining winners, etc.

I think this will work well from an MVC standpoint too because I'm not passing models to the view that have methods.  The Race class will really just be there to hold EF data and will make for a clean model to use for adding or updating races from a view.

Thanks for the help everyone!

Body:
I would implement a RangeConstraint with an indicator of the type if you're concerned about the database layout, this will give you one table for range constraints and an identifier (1=Age, 2=Weight, 3=IQ, etc), then the min and max is all you need otherwise. THen the PassesConstraint bit should just use a selector from a dictionary somewhere Dictionary<RangeConstraintType, Func<RaceParticipant, int>> rangeSelectors where you give it the constraint type, it returns a function that given a participant will give back the value to be validated against the range. Something like:

var _rangeSelectors = new Dictionary<RangeConstraintType, Func<RaceParticipant, int>>() {
    { RangeConstraintType.Age, (participant) => participant.Age },
    { RangeConstraintType.Weight, (participant) => participant.Weight },
    ...
};

Then in your PassesConstraint it just..

public override bool PassesConstraint(Race race, RaceParticipant participant)
{
    var participantsMetric = _rangeSelectors[_rangeConstraintType](participant);
    return participantsMetric < maxValue && patricipantsMetric > minValue;
}


答:
You are running into a limitation of Entity Framework that encourages what each type of object in your domain model to map directly to a single schema construct.  Creating sub types of RaceConstraint sounds like a good idea from an OO perspective but then the Anemic Domain Model is a more encouraged pattern using this framework anyway.

RaceConstraint should be the entity type and all the different possible constraint properties should exist in this one entity.  Display and Validation text are not well represented here, and may be more appropriate as references to an enum or a resource file as each individual constraint property in your RaceConstraint object may have a unique message.

To maintain the OO design however, you can translate your domain model to a view model that is not Anemic, however some would consider it bad practice to have business logic like PassesConstraint in your View Model or your Domain Model as well.  These are the two schools of thought on this.


答:
The response you are almost always going from most manager-types is something like:

"It's not worth it, it works now, and it will cost time to change."

And in general, this is valid.  However, this is not always a valid argument, because the core issue surrounding "Not Invented Here" syndrome is not whether things work or don't work, but that technology is being pointlessly re-written, wasting company hours, and detracting substantial value from the product being delivered.

You need to determine if Not Invented Here is actually taking place before deciding what to do. The internal tech may have been written for a reason.

Signs that the Tech is Rewritten for a Reason:

The tech you are selling is also the product.  If you are a database vendor, using MySQL code, no matter how much time it will save, is a dangerous idea for many reasons.

The internal tech is well-maintained and effectively addresses shortcomings of the off-the-shelf solution, while still providing comparable base functionality.

The tech improves the productivity of the entire development team, and new developers are easily sold on why it is in use.

There are other examples where the company has successfully adopted other external technologies.

Your business would be immediately and seriously impacted if the OTS solution were discontinued or broken.

The business is so large that it has the resources to write high-quality tools at a low cost (for example, Google may be able to write a database that costs less than a $1000/seat MS SQL license)

In other words, the team understands the drawbacks of re-solving already-solved problems, but judiciously made exceptions where it made sense from a business perspective.

Signs of "Not Invented Here":

Seems like everything is internal, and there are excuses for everything: "uh, it was too slow", "uh, it's Microsoft, we hate Microsoft", "uh, it looks really hard to use", etc.

For cases where external tech is being used, you hear "yeah, well it stinks and we plan on writing our own eventually".

The owners of those components don't have other jobs they are capable of working on.

You see most new developers coming in with a widely-accepted skill-set, but it takes considerable time for them to ramp-up to the internal tooling

After careful analysis, it becomes apparrent that switching from the OTS solution to a custom or other OTS solution in the "what if it's discontinued!" scenario would have minimal business impact.  For example, if String.Join() were removed from the .NET Framework, re-implementation to a custom StringJoin() method would be trivial.

In other words, NIH is the pattern of failing to stay objective and realistic in cases where external tech is being used instead of one's own code.

When tech is rewritten for a reason, bringing up your concerns should be praised and appreciated by your superiors. It should have been a careful decision when the tech was implemented, and reviewing the decision occasionally is good for the business. Things do change over time and you may have a valid point. If you can provide numbers about time wasted in the past, projected costs to switch, and other information, you could (in theory) make a case for switching.

Understand that given your experience, they may not agree with your numbers, but regardless, they should at least hear you out. It may take time to gain respect.

If the conversation can't even be brought up, even if you're being polite, it might just be "Not Invented Here". In which case, it is most likely a personality or political issue that you probably cannot fix easily. Working in an environment that is heavily bogged down by constant reinvention is toxic to the developers and the business. Run.

(Side note: In most companies, there is always an element of NIH, but it's at a tolerable level, and as long as they regularly review their code and practices. In the long term we are all guilty of it to a degree, but it never becomes an issue.)


答: those who don't know history are condemned to reinvent it</p>

Title: Do I need to understand algorithms and data structures to be called a programmer?

Body: It has been six years since I have been coding. Coding into all kinds of things like ActionScript, JavaScript, Java, PHP, Ajax, XML HTML, ASP, etc. I have used arrays, maps, linked lists, sets, etc and wherever I worked people like me. But whenever I am interviewed it is very likely that people ask me question on hashes, trees, stacks, and queues. Some questions are on juggling some sorting algorithms.  I don't know if I should really know them or should I stop calling myself a programmer. There is something in me which also tells me even if people who are asking all these questions select me, they will never be making me work of these things. Am I really required to know all this?</p>


问:
In JSF where do objects like PhaseListeners fit in the MVC pattern?
When it comes to JSF, I've had trouble distinguishing where certain objects I create fit into the overall MVC pattern.  The View is simple enough since that's handled by the .xhtml template but when it comes to objects like:

Action/Change Listeners

PhaseListeners

Validators

Navigation Beans

Converters

Filters

At first I'd assume some of these belong to the Controller but I've seen a number of statements here and elsewhere on the web stating that for most developers using an MVC framework, specifically JSF, the majority/entirety of the Controller is already implemented by the framework.

The following Q&A: https://stackoverflow.com/questions/10111387/understanding-jsf-as-a-mvc-framework
, while very informative still leaves me feeling pretty vague on the matter.  The accepted answer states that consumers of JSF do not implement Controllers while the thesis linked to at the bottom of the answer clearly states that Listeners are a part of the Controller pattern.

答:
In essence the accepted answer in the link you provided is correct.  The MVC pattern only makes sense when considering that M, V, and C can all directly communicate with each other.  This is possible in a desktop application, however the web is inherently stateless and request response based.  JSF and other component based web frameworks seek to bridge that gap.  They do this by providing to you a prebuilt Controller in FacesServlet.

What does that make Managed Beans and PhaseListeners then?  BalusC says is best here:

https://stackoverflow.com/questions/5104094/what-components-are-mvc-in-jsf-mvc-framework

The combination of all your JSF code can be considered the traiditional View in the MVC pattern, the View Model being your entities, and the View Logic is your Managed Beans, Converters, EL Expressions, Validators, and finally PhaseListeners.  They only make a difference with respect to processing logic that manipulates the View itself and the ViewModel.

M - Application and DAO Tiers (M - Entities, V - JSF Marktup, C - JSF Code and Logic) C - FacesServlet

OwnerDisplayName: TEL


问:
How do you balance between "do it right" and "do it ASAP" in your daily work?
I find myself pondering over this question from time to time, again and again. I want to do things the right way: to write clean, understandable and correct code that is easy to maintain. However, what I end up doing is writing patch upon a patch; just because there is no time, clients are waiting, a bug should be fixed overnight, the company is losing money on this problem, a manager is pressing hard etc., etc.

I know perfectly well that in the long term I am wasting more time on these patches, but as this time spans months of work, nobody cares. Also, as one of my managers used to say: "we don't know if there will be a long term if we don't fix it now."

I am sure I am not the only one entrapped in these endless real/ideal choice cycles. So how do you, my fellow programmers, cope with this?

UPDATE:
Thank you all for this interesting discussion.
It is sad that so many people have to choose daily between a quantity and a quality of their code. Still, surprisingly many, people think it is possible to win this battle, so thank you all for this encouragement.

答:
I see my job as providing the best quality software that is possible within the time constraints allowed for the project.  If I am concerned that the level of quality will be low, then I will engage the project owner.  I describe my concerns and discuss the potential risks of deploying the software in that state.  One of 3 things will happen at this point:

The project owner will not want to accept the risks and will move the schedule back to allow us to spend more time on software quality.

The project owner will not want to accept the risks but cannot move the schedule back.  If this happens, then we need to negotiate on what features/functionality to remove from project scope in order to spend more time on software quality for the main parts of the application.

The project owner will accept the risks and the low quality software will go out on schedule.  Sometimes the business risk of deploying nothing (or deploying late) is much greater than the business risk of deploying low quality software, and only the project owner can make that decision.

Writing software is a lot like painting a portrait.  It is impossible to say that a portrait is done "right" or "perfect".  Perfect is the enemy of done.  You could literally spend 1 month working on a single method and it still not be considered "perfect" by some.  My job is to paint a portrait that the customer is happy with.


答:
Breaking Things Is A Skill

I've worked at far too many places that embraced the "if it isn't broken" argument to the point that they fail to innovate, and when they finally are forced to innovate they over react by changing everything. Simply because they lack the experience of breaking things.

It takes maturity, skill and experience to break things.

Development teams that always play it safe are the easiest for a competitor to surpass. Only teams that have failed, made mistakes, and broken things are able to truly do honest risk assessments.

Keeping The Status Quo

While it's true the current system meets the current business requirements. That isn't true for the future unforeseen changes to those requirements. As the old proverb says "fortune prefers the prepared".

This question has nothing to do with SQL or performance. It's about asking the question "is there a better way?" and not being afraid to try an alternative.

Your boss suffers from a case of Keeping The Status Quo.

The Mayan's

Nothing is truly working perfectly.

The Mayans kept growing their food on the side of mountains. Until all the nutrients were washed away, and they had no way to feed their people. They kept doing things the same way until it was too late.

Assuming you'll have time to fix a problem when the problem presents itself is a mistake.

What To Do?

Your boss suffers from a case of conditioning. People who accept the status quo often do so, because they lack the ability to make difficult decisions. When faced with a challenge they will tend to choose the option closest to what they are familiar with.

Fear for him is a big motivation. Fear of the unknown or changing conditions shakes his perspective of what is the status quo. He will tend to try and return the conditions back to normal as quickly as possible.

You need to present ideas in a non-conflicting way. Try to find common ground between what you would like to do with what is already the status quo. Present arguments that reduce his fear of change, and offer reassurances that you want to complete a task that won't cause significant change.

Take Baby Steps

It would be best to offer changes that move the project in the direction you want, but via small incremental projects. Rather then hit your boss with the big question about supporting SSIS. Offer to create a separation layer in the code that would allow you to plugin "alternative" methods for processing tables with large attachments. You can then progress to recommend SSIS with all the prerequisites have already been added to the project. This reduces the risk your boss envisions by accepting the change.

It Takes Time

My experience has been that risk takers keep a project moving, and status quo keepers are like a brick wall. Persistence is your only option to breaking down their barriers. Expect to keep hearing No to your inquiries.

When the time comes to innovate. Your boss will turn to you quickly, because you demonstrate fearlessness in the face of change. Something a status quo person will be looking for, and you will be rewarded for your efforts. Even if none of your previous inquiries have been accepted. You will quickly become an irreplaceable asset in a company faced with change that embraces no-change.


问:
Frustration with Java Swing layout managers
I have been trying for years to master Swing layout managers with no success.  Every time I need to do something with Swing, it is like pulling nails to get the visual components to line up the way I want them to.  I am familiar with frameworks like Matisse but that's not the point.

My question is:  Why does Swing even need layout managers?  It seems like an overcomlicated paradigm.  What I would like to be able to do is jave a simple JFrame and then for each component (like JLabel) simply specify X and Y coordinates where I want it to be situated -- done deal.  Can anybody explain what is wrong with this simple approach that would work predictably 100% of times?  Or is there an actual layout manager that does things exactly like this?

答:
Maybe you're too young to remember when programming without layout managers was more common.  Either you had to fix your screen at one size, which worked great unless you actually needed to share your application with someone who used a different screen resolution, or you had to deal with scaling that looked really bad.

Part of the problem is what you might consider "natural" and "obvious" scaling is actually quite complex under the hood.  Some components, like a text area, can naturally be resized in both directions and still look pretty good.  Some components, like a combo box, only look okay when scaled in the horizontal direction, and some components, like buttons, rarely look natural when scaled more than a little bit in either direction.  Layout managers let you mix and match components and still make the scaling look natural.


问:
How to write "SMART" Objectives as an agile developer?
Like many corporations the company I work for is transitioning to a performance review system based on SMART objectives. My team is a high functioning agile development team employing practices from Extreme Programming. To our great benefit our employment of agile practices has the full support of immediate and upper management.

To accomplish work our team utilizes three week iterations. Beyond the immediate iteration we have a general plan laid out into quarters. Meaning that what we will have accomplished a few quarters from now is a lot hazier than what we will be accomplishing in the immediate quarter. We certainly have a general idea of where our project is headed, but the keyword here is general.

Given our approach to project planning members of my team, including myself are finding it difficult to write objectives which are specific, measurable, attainable, relevant, and time-bound (SMART).

Two existing questions on SoftwareEngineering.se do a good job of addressing some of our concerns:

What is an example of a good SMART objective for a programmer?

Are SMART goals useful for programmers?

However, the questions elicited more general responses than specifics for dealing with SMART goals when working on an agile development team. As an agile developer how do you write five to seven, year long objectives which are specific, measurable, attainable, relevant, and time-bound?

答:
This answer is written from the perspective of someone who had such a performance management system put in place around an Agile team; like you, everyone on the team realized the difficulty/uselessness of year-long SMART goals applied to an Agile group, where, when fully functioning, the implementation of Agile can be considered inherently/already SMART.

No, really! Call the following a rationalization if you need to (if the logic is half-baked...), but explaining it to reviewers outside the immediate organization has set the stage for the actual "goals" we put in the performance management system.

S for specific: during each sprint planning, the team agrees on a specific set of tasks to achieve, and commits to doing them.  The tasks (and the user stories), answer the questions of what do I want to accomplish, purposes/benefits of accomplishing the goal, who is involved, where it takes place, and constraints.

M for measurable: the list of these tasks, plus the movement of the tickets throughout the sprint, from development to code review to QA to release (or whatever your flow is), answers the questions of how much work and when will it be accomplished.

A for attainable: functioning Agile groups don't typically commit to something in the planning stage unless it is clearly attainable -- all the pieces are there to know how to accomplish it

R for relevant: questions like is it worthwhile, is it the right time, does it match our other efforts -- stories and tasks don't get pulled into a sprint, and committed to, unless the answer is yes to all these questions (typically...YMMV)

T for time-bound: a sprint is necessarily time-bound, be it 2 weeks, 3 weeks, more, or less.

If you understand/convince yourselves that your quarterly work (and thus your year-long work) is itself one big SMART goal, and that you know you're achieving your goals because the team is performing well, velocity is positive, releases are happening, then you get to the point of your question, which is ultimately how to translate a SMART process into a set of SMART goals for the benefit of someone else.

I've been able to do this successfully in the past by writing something that to me looks vague and, well, not very SMART, but is in fact perfectly acceptable for others.

A couple examples that have passed muster elsewhere for me:

"I want to release a new version of WidgetMaker every three months in the next year, by following our internal software development process, to align with the overall product development schedule (blah blah)."

"I want to increase the team's development velocity by n% from release A to release B, by focusing on incremental changes to the process of backlog grooming, in order to increase our effectiveness and decrease delays in shipping the product."

You know and I know that these are not the guiding principles of your actual development group, but they aren't wholly unrelated, and in my experience are the types of things that appear really SMART and useful to the people outside your immediate organization (without being outright lies or totally lame).


答:
definitely pick his brain in the interview on real problems and technologies that you currently have or intend to use

assuming he/she is a competent and imaginitive senior developer, decide to hire or not based on if you think you can learn from him/her and work well with him/her

you're not interviewing your future boss, you're interviewing your future mentor. Don't pick someone who knows all the answers but can't teach

Title: How do you interview someone with more experience than you?

Body:
The company I'm working for is looking to hire a senior developer with more experience than me, and they expect me to do the technical part of the interview. I've only been programming a few years and am not sure I have the knowledge needed to evaluate the coding skills of someone who has greater understanding/experience than I do.

Can anyone recommend some technical interview questions to ask that are a good means for evaluating higher-level programming skills, but still be ones I can understand?

I would say I'm past the jr. programmer level, but nowhere near senior. Most of what I've done is built small apps (web and desktop), some of them fairly complicated, but all of them have been meant to be used by no more then a handful of users. I feel I have a decent understanding of most programming concepts and am capable of learning/teaching myself just about anything, however I lack experience. As my boss is fond of telling me, "You don't know what you don't know".

In particular, things we'd like the person we hire to have experience with (that I don't have) is: Multi-tier development, multi-user environment, large-scale application development, two-way messaging, shared sessions, and Multi-threading/BackgroundWorkers.

UPDATE:

In response to Thor's comment below, we hired someone a few months ago and I think it has been working out great. I am learning a lot, not just about coding but also about things like design patterns, software architecture, documentation, and how other larger programming teams get stuff done. Its not always easy having someone come in and point out better ways to do things you have done, but if you can swallow your pride and be willing to try out new things you can learn a lot.

The interview process went better than I expected. I started asking questions about things I was familiar with, then asked some questions about some things I was struggling with. Whenever the interviewee said something I didn't understand, I'd ask them to explain it to me and then write it down so I could look it up later on. Overall, I felt I was able to get a pretty good idea of the applicant's skill level, intelligence, and what they'd be like to work with.


问:
Algorithm for an exact solution to the Travelling Purchaser Problem
do you know of any algorithms which give an exact solution for the Traveling Purchaser Problem. I can only find heuristic and probabilistic approaches.

I do have implemented a genetic algorithm so far, which by its nature does not terminate by itself an does not always yield the optimal result. Thus I'm looking for an exact solution to the problem such that I'm able to compare my solution to an exact / optimal value for a given test data set.

For those of you who haven't heard of the Traveling Purchaser Problem (TPP), this is not the Traveling Salesman Problem (TSP), but a generalization of it. It thus is also NP-hard.

答: You may try integer linear programming, but I can give you only travelling salesman formulation, but it should not be difficult to modify, once you gat the idea. Other option can be to use some constraint programming library (such as JaCoP: http://www.jacop.eu/). In my experience it is possible to solve NP-hard problems with several hundred nodes using normal desktop computer. If you data is bigger, than you will have to use some approximation/genetic programming and things like that, you will not be able to get the exact solution.</p>


问:
Need interpretation of section in C# specification
I am reading the C# specification.  I could use clarification on a segment:

C# has a unified type system. All C# types, including primitive types
  such as int and double, inherit from a single root object type. Thus,
  all types share a set of common operations, and values of any type can
  be stored, transported, and operated upon in a consistent manner.
  Furthermore, C# supports both user-defined reference types and value
  types, allowing dynamic allocation of objects as well as in-line
  storage of lightweight structures.

What does “in-line storage of lightweight structures” mean in this context?

答:
It means that value types are stored directly where you define them, which makes them more efficient when compared with reference types.

What exactly does that mean? If you have a local variable of a value type it will be usually stored directly on the stack (but there are many exceptions). If you have a field of a value type, it will be stored directly in the enclosing class or structure.


答:
Well, Swing need layout manager because its supposed to be cross platform, and thus will render components of different size on different platform. By using math rule to line elements it make it much more portable.

By the way, if you want good control over the placement while still remaining fluid, you can check GroupLayout. Its not perfect, but it give you a relatively fine control, and I use it very often

Title: Frustration with Java Swing layout managers

Body:
I have been trying for years to master Swing layout managers with no success.  Every time I need to do something with Swing, it is like pulling nails to get the visual components to line up the way I want them to.  I am familiar with frameworks like Matisse but that's not the point.

My question is:  Why does Swing even need layout managers?  It seems like an overcomlicated paradigm.  What I would like to be able to do is jave a simple JFrame and then for each component (like JLabel) simply specify X and Y coordinates where I want it to be situated -- done deal.  Can anybody explain what is wrong with this simple approach that would work predictably 100% of times?  Or is there an actual layout manager that does things exactly like this?


答: I'll add "yes, of course you can still call yourself a programmer".  But what sort of a programmer do you want to be?  I think the very best programmers have at least some grounding in the theoretical basics. They know why they chose a particular data structure/algorithm as well as the trade-offs that come with that. I expect any developer I interview to have at least a basic understanding, even if they don't use the same jargon (although not knowing the jargon means you'll find it more difficult to communicate with other developers).


答:
You could point out to your boss that SSIS is, in fact, an older technology layer than the .NET Framework, if you go back to its roots as the "Data Transformation Framework" of SQL 7.0.

Where your boss might have a point is in the fact that SSIS is only a part of the Standard and Enterprise versions of Microsoft Sql Server; that's a rather big chunk of change for your clients to pony up, when your application, in a small business scenario, may well be perfectly fine with Sql Express (or MySQL, for that matter, which works with ADO.NET but can't use SSIS integration).

Now, let me be perfectly clear; IMO, NIH is almost never a good thing for a software development house. It locks you out of a lot of very powerful tools and services. It's also hypocritical on its face; did your company write Visual Studio? How about the .NET Framework? Sql Server? Windows? No. You build your software on top of the tools and platforms you already have (and so do your clients). Therefore, if you see a tool that is gaining general acceptance, and that could be useful in performing your core business, you adopt it, and you learn to live with the risk that you will have to maintain your implementation to keep up with the latest versions of those tools, or even replace them. I bet your boss first developed the software to run on Windows 95/98 or thereabouts (if not long before that, like 3.0/3.1). If so, he's seen half a dozen versions of Windows workstation OSes come and go, and had to update his software to run on the newer platforms, and he's facing another one with XP officially EOLed. While he may complain, that's simply the cost of doing business.

However, a NIH attitude doesn't necessarily follow from a refusal to accept one, or even a number, of technologies that may be viewed as helpful. Those refusals could be based on perfectly valid cost-benefits analyses. I work for a video surveillance and alarm monitoring company, and we make decisions to support or not support various new technologies or products on a daily basis. Usually, the decision to accept a new technology, and the pain of bodging it together with our existing heap of supported viewer and alarm management software, is based primarily on what it's worth to our customers. I recently finished a big integration project with a new type of DVR, simply because one of our biggest existing customers said they were upgrading to that DVR from another big-name but technologically-lagging DVR product, and they would do it with or without our help. On the other hand we regularly reject new manufacturers, even major household names, simply because our customers don't use it and we see no value in starting to offer it, even if it loses us a few potential customers that have it and don't want to pay for our version of the same thing.


问:
How signing out a CLA prevents legal issues in open-source projects?
For example: yeoman. It's licensed under a BSD license. The CLA form (Contributor License Agreement) isn't project specific, and it can be signed electronically.

How and what issues can signing out this agreement prevent?

Does it matter how big or minor contribution I made?

Why some projects require signed CLA to accept patches, while others don't? (eg. node.js vs rails)

答:
Benjamin's answer was pretty clear but I'd like to emphasize a single point. CLA's protect companies using or contributing to projects. Companies, particularly large ones, are terrified of being caught off guard by legal issues. I've had corporate lawyers tell people I know that even in slam dunk cases where the law is on your side, you can only be about 60% sure that you'll win the case.

Consider the situation of a company, particularly a very large one with lots of revenue, builds a product around an open source tool. They gain customers, build out infrastructure and hire employees. If all of a sudden a contributor to the original tool sues them for patent or copyright infringment, the company is in a lot of legal hot water. If they stop providing their product, they've wasted money on infrastructure and employees they don't need and more importantly, they're pissing off customers. On the other hand, if they stop providing their project, their liability ends while the case in figured out.

Considering the current legal software landscape, CLA's are the best way to make companies feel comfortable using and contributing to open source software. It's not ideal (it'd be nice to never have to deal with any of this legal stuff) but right now it's one of the few ways of making these contributions pos


问:
Is there an advantage to using WCF or WebAPI for mobile?
I'm looking at doing my first mobile development using Mono Touch and Mono for Android.  I'd like them to communicate with an ASP.NET MVC 4 site I'm designing.  I've worked with WCF and WebAPI in the past but I'm wondering if there are any quantifiable advantages to using one over the other in this context?

答:
Here is a great article about that particular topic; hopefully this helps you out.

Is there still use for WCF? when should I choose Web APIs over WCF?

Recall my points from before - HTTP is a lot more than a transport
  protocol; use SOAP across the board and consider HTTP as no more than
  another way to pass messages.

If your intention is to create services that support special scenarios
  – one way messaging, message queues, duplex communication etc, then
  you’re better of picking WCF

If you want to create services that can use fast transport channels
  when available, such as TCP, Named Pipes, or maybe even UDP (in WCF
  4.5), and you also want to support HTTP when all other transports are unavailable, then you’re better off with WCF and using both SOAP-based
  bindings and the WebHttp binding.

If you want to create resource-oriented services over HTTP that can
  use the full features of HTTP – define cache control for browsers,
  versioning and concurrency using ETags, pass various content types
  such as images, documents, HTML pages etc., use URI templates to
  include Task URIs in your responses, then the new Web APIs are the
  best choice for you.
      If you want to create a multi-target service that can be used as both resource-oriented service over HTTP and as RPC-style SOAP service
  over TCP


问:
Help understanding MapReduce Sort example
From Section 5.3 of Google's paper describing MapReduce.

"A Map function extracts a 10-byte sorting key from a text line and
  emits the key and the original text line as the intermediate key/value
  pair. We used a built-in Identity function as the Reduce operator.
  This function  passes the intermediate key/value pair unchanged as the
  output key/value pair. The final sorted output is written..."

I don't understand how the actual sorting happens. As far as I understand, they Map function extracts a key value pair, and then the Reduce function somehow spits out the data sorted. What is a "sorting key"?

答:
Have a look at this YouTube video, of a professor explaining the concepts involved in the MapReduce algorithm.  Unfortunately, all the code is in Scheme, so readability's not the greatest, but he does a good job of explaining what goes on.

Basically, MapReduce has more than just those two steps.  It goes like this:

Map: for each input, produce 0, 1 or more key-value pairs

Sort: Gather the key-value pairs and sort them by their keys into a group of buckets

Reduce: Each bucket gets reduced in parallel to a single result.  Results from each bucket are then combined (reduced) to a final result.

The sorting step is basically there so you can run the Reduce operation in a distributed, parallel fashion instead of having to do the whole thing serially, which would require the entire Reduce task to be handled by a single system, which kind of defeats the purpose.


问:
Versioned Resources to Improve Cacheability
Here's an API concept which could be useful for performance optimisation. It's an example of key-based cache expiry applied to a broader internet-wide context instead of the internal Memcached-style scenario it seems to be mostly used for.

I want to make API calls almost as cacheable as static images. Using a news/feed subscriber as an example, which we might poll hourly, the idea is to send a last-updated timestamp along with each topic (it could just as easily be a version number or checksum):

```<code>{
  username: "Wendy",
  topics: [{
    name: "tv",
    updated: 1357647954355
  },
  {
    name: "movies",
    updated: 1357648018817
  },
  {
    name: "music",
    updated: 1357648028264
  }]
}
</code>```

To be clear, this resource itself comes directly from the server every time and is not cached on the edge or by the client. It's our subsequent calls for topics that we can aggressively cache, thanks to the timestamp.

Assuming we want to sync all topics, we'd have "N" further calls to make in a naieve implementation (/topics/tv etc). But because of the timestamp, we can construct a URL like /topics/tv/1357647954355.json. The client usually doesn't make a call at all if it's already seen (and cached) the same version of that resource. Furthermore, even if it's new to the client, an edge cache (e.g. a reverse-proxy like Squid, Varnish, or service like Cloudflare) probably has seen it before, because some other user has probably opened the latest version of this topic already. So we still bypass the application server; the server only ever creates topic JSON once after the underlying resource has updated. So instead of N+1 calls to the server, the client probably makes a much smaller number of calls, and those calls will rarely hit the app server anyway.

Now for my question All this seems feasible and worth doing, but my question is if there's any prior art for this kind of thing and in particular, any HTTP standards to support it. I initially thought of conditional caching (ETags and modified dates), and I think they'd help to optimise this setup further, but I don't believe they are the answer. They are subtly different, because they require calls to be passed through to the application server in order to check something's changed. The idea here is the client saying "I already know the latest version, please send that resource back to me". I don't think there's any HTTP standard for it, which is why I propose a URL scheme like /topics/tv/1357647954355.json instead of some ETag-like header. I believe some CDNs work this way and it's surprising to me if there's no real HTTP standard around it.

Update:
On reflection, an important special case of this is what a web browser does when it fetches a new HTML page. We know it will immediately be requesting CSS+JS, so the same versioning/timestamp trick can be used to ensure those static resources are cache-friendly. That this trick has not been formalised by the spec gives me confidence that unfortunately there is no HTTP standard for it. http://www.particletree.com/notebook/automatically-version-your-css-and-javascript-files/

Body:
The solution is smart, but I would question if there is even any need to make this a non-cache request to fetch the JSON for dynamic processing using JavaScript at all.

If you were to just emit the latest version of the URLs directly in <script> and <link> elements as part of the HTML page that you serve up that would result in one less resource request. I guess it depends on exactly how large the HTML is that you're serving up in the first place, but even that could be served up with an ETag based on a hash of the latest dependent resource timestamps and, assuming they haven't changed, that would result in a 304 not modified for the HTML itself.

This way you're avoiding any JavaScript magic at all (which has to add bloat for the download logic too) and reducing requests by at least one.


答:
The sorting is dependent on some implementation details and additional functionality in Google's runtime. See section 4.2:

We guarantee that within a given partition, the intermediate
  key/value pairs are processed in increasing key order. This ordering
  guarantee makes it easy to generate a sorted output file per
  partition, which is useful when the output file format needs to
  support efficient random access lookups by key, or users of the output
  find it convenient to have the data sorted.

The system also allows an arbitrary partitioning scheme (mentioned in section 4.1). The sorting system uses this scheme:

The partitioning function uses the initial bytes of the key to
  segregate it into one of R pieces.

Thus when the Reduce function is run on each partition there are no changes to the data but the output is guaranteed to be in correct order (presumably there's nothing special about the implementation of this - it's just a simple local sort of some kind).

Once you have your sorted partitions, all you have to do then is concatenate them in the order of the initial bytes that were used to make the partitions and you have a fully sorted list.

(I'm taking a "sorting key" to be a summary of the value that's designed such then when the keys are sorted the values are also in the correct sorted order, at least to a reasonable approximation. Simply truncating the first letters of a string would be enough to make a crude sorting key)

Title: Help understanding MapReduce Sort example

Body:
From Section 5.3 of Google's paper describing MapReduce.

"A Map function extracts a 10-byte sorting key from a text line and
  emits the key and the original text line as the intermediate key/value
  pair. We used a built-in Identity function as the Reduce operator.
  This function  passes the intermediate key/value pair unchanged as the
  output key/value pair. The final sorted output is written..."

I don't understand how the actual sorting happens. As far as I understand, they Map function extracts a key value pair, and then the Reduce function somehow spits out the data sorted. What is a "sorting key"?


问:
How much time a week do you spend on extracurricular programming?
Background: I'm a microsoft DBA/IT type person by day, an iOS and Mac developer by night. I have one app in the App Store and another one in the works. I try to spend as much time as possible working on my two apps, but with a new daughter and other (non computer) hobbies, I find it hard to spend more than a few hours every week programming.

I'm wondering how this compares to other developers. I see a lot of apps out there written by single developers who don't do iOS development as their main job. Are they spending 4 hours a night working on their projects, or do they just plug away for a year or two before releasing anything?

答:
Not enough as I'd like to.

I used to basically spend most of my time doing just that uni. Then when I began to work I was spending most of my evenings and week-ends working on personal projects (some relating to my job to try to improve ways things were done at the office) and to learn new things.

Then I switched to jobs not allowing too much personal development at the office if not relating to their core-products.

Then I met someone.

Then I had a kid.

Guess soon I'll have a garden and that will be the end of it :)

I think there's no "appropriate" number of hours for this, but needless to say that if you want to be and remain an expert at the top of your game in your areas and even in emerging areas, then you need to spend an awful lot of time.


答:
Other toolkits have equivalent concepts (e.g., Tk has geometry managers) as well, and they are absolutely central to having a GUI that is not fixed at one exact size. That matters when:

you have fonts that can change in size for accessibility reasons, or

you have different sizes of screens, or

you have resizable windows, or

you have variable amounts of content in some components.

That's not a complete list of reasons why you might want adaptive sizing, but it does illustrate that you may well not have control over the precise placement and sizing of things even if you might want it. Far better to stop trying to control things at the pixel level and to instead leave the computer to look after that for you following more general rules that you describe; what layout managers do is enforce those rules.

FWIW, writing a good layout manager is hard. Really hard. In fact, the one I know of that gives the best layouts in my experience (Tk's grid manager, which is a sort of souped-up GridBagManager except without the suck) is internally a complicated simultaneous equation solver with some scary heuristics to ensure that an answer pops out even when the user's directives don't give a solution. It's also had a few man-years of effort poured into its development (really!) so I wouldn't expect it to be reproduced easily. Because of the general difficulty in doing layout managers well, most people who write them tend to write very specific ones that don't actually do a particularly smart job but where the implementation is simple enough that it is at least easy to handle the simple cases they actually care about.


问:
Newbie ASP.NET developer being forced into MVC4 with WebForms
I recently got hired on as a new ASP.NET developer (C# code behind).  When I arrived, I was told that they were moving to MVC 4, and so I bought two books on that.  However, the other day I learned that they are NOT using Razor, but using WebForms.  Most of the results via Google returned articles from before the WebForms view engine was apparently selectable as an option instead of Razor, but my question is this:

Is it possible to learn MVC through WebForms, and not Razor?  By possible, I mean is it "worth the time", or should I stick with Razor (as covered in both of my books) and slowly adapt that knowledge to WebForms?

Are there any drastic changes that need to be understood when learning MVC from the WebForms perspective?

Thank you for your time.

答:
If the culture, work environment, and boss are all acceptable, I wouldn't worry too much about it for two reasons:

If your development team is progressive enough to use MVC 4 and .NET 4, then they will probably discover the benefits of the Razor view engine very soon and you'll write new views with the Razor syntax in the near future. [Remember ASP.NET MVC supports the use of both the Razor and WebForms views in the same project with the default configuration.]

With the advent of many exceptional MV* JavaScript frameworks, the traditional ASP.NET MVC view (and consequently view engine) is becoming less and less relevant. For example, we're using Knockout on my current project, and I can honestly say that it wouldn't break my heart if my boss insisted on Web Forms views. It would almost make no difference at all. The important code resides in the Knockout view model.