问:
What are some good assignments for an introductory course, to reach today's students?
I periodically teach an introduction to programming course using Java. I want to give my students some exciting assignments that they can relate to or find interesting. At the very least, I want assignments that make sense and have an internal cohesion (for example, some very bad programming exercises seem contrived just so that you have to use the most recent programming construct covered).

To give you an idea of scope, here's what's being covered:

The assignments must be in Java, using some external library can be done, but it would need to be a simple API and not a full framework

Variables, Primitives and Strings

Console input and output

if, for, while

Arithmetic and logical operators

Simple graphics with line and shape drawing

Static methods

One-dimensional arrays

The students will not go into advanced topics (e.g., no recursion, no emphasis on inheritance). Thus, I'm not looking for complex projects: "Have them write a C compiler. I did it when I was 5 and it was the only way I learned!"

If you have ideas that are more advanced than the scope, please post them on the "Challenging" question linked below, and not this one.

Instead, what I'm looking for are interesting ideas that can be accomplished in a short program. For example:

Students can write a console version of the "Star Wars Name" Generator. This is effectively reading Strings and using substring, but I think it's fun. A similar variation would be a "Mad Libs" program. I used this one five years ago, and perhaps it's already "stale."

Using some trig supplied to them, students can draw regular polygons, and create interesting spiral shapes.

It's also not out of the question to use some simple animation class with most of the code supplied to them. And if you know a Twitter or Facebook service that can be accessed with a simple API, I would be very interested to know.

Please note that this question is different from the "Challenging Java questions for beginners" Question. I'm not looking for challenging per se, just interesting. I think if students work on something where they can easily answer "why would anyone ever want to program that?" then they will learn better.

Even simple problems like computing Miles per Gallon can be good. Although, if there's a way to update it to be more relevant, all the better. If you have an exercise from somewhere else (a book or a website), please cite the source.

To help you think about the typical freshman today, check out the Beloit Mindset list, for many examples that will surely make you feel old.

答:
In High School, I took an introductory programming class, and we used Karel J. Robot. It provides a gui for viewing your robot, and has a very basic set of sensors and movement methods which you have to extend in order to make it do interesting stuff. I think its good because robots are easy to understand for people who haven't yet developed a grasp of the difference between software is.

There is also Processing, which I just discovered, which was originally designed to teach programming, and its also in java.


问:
Need help understanding "An Image Signature for any Kind of Image"
I'm trying to implement the paper titled An Image Signature for any Kind of Image, but I'm having trouble understanding what they mean in this paragraph:

For each column of
  the image, we compute the sum of absolute values of differences between adjacent pixels in that column. We compute
  the total of all columns, and crop the image at the 5% and
  95% columns, that is, the columns such that 5% of the total
  sum of differences lies on either side of the cropped image.
  We crop the rows of the image the same way (using the sums
  of original uncropped rows).

First, what do they mean by "sum of absolute values of differences between adjacent pixels in that column"? If start at the top-left pixel and work downwards (down the column), we can compute the difference between (0,0) and (0,1), but what about the next pixel? Am I supposed to compute the difference with just the pixel below, or the pixels on either side, or perhaps even the 4 or 8 neighbours?

And then, as I understand it, we sum these differences for each column such that each column is reduced to a single number?

Then we use this information to crop the left and right edges of the photo, right?

答:
I didn't read your link, but from your question...

"Sum of absolute values of differences between adjacent pixels in that column":

```<code>sum = abs(pix1 - pix2) + abs(pix2 - pix3) + ...
</code>```

You perform this computation for pixels 1 and 2 in the column, then 2 and 3, and so on. Do this for every column. Then sum all of the column sums together.

Start a new sum, adding column sums from the left. Once that new sum gets over 0.05 * sum_of_all_columns, you've passed the 5% threshold and know which column to crop at on the left side. Do the same thing on the right side going the other direction.

Basically they're looking to automatically crop out edges of the image that have no interesting features.

ContentLicense: CC BY-SA 3.0

Body:
I didn't read your link, but from your question...

"Sum of absolute values of differences between adjacent pixels in that column":

sum = abs(pix1 - pix2) + abs(pix2 - pix3) + ...

You perform this computation for pixels 1 and 2 in the column, then 2 and 3, and so on. Do this for every column. Then sum all of the column sums together.

Start a new sum, adding column sums from the left. Once that new sum gets over 0.05 * sum_of_all_columns, you've passed the 5% threshold and know which column to crop at on the left side. Do the same thing on the right side going the other direction.

Basically they're looking to automatically crop out edges of the image that have no interesting features.


问:
Why is it a good idea for "lower" application layers not to be aware of "higher" ones?
In a typical (well-designed) MVC web app, the database is not aware of the model code, the model code is not aware of the controller code, and the controller code is not aware of the view code. (I imagine you could even start as far down as the hardware, or perhaps even further, and the pattern might be the same.)

Going the other direction, you can go just one layer down. The view can be aware of the controller but not the model; the controller can be aware of the model but not the database; the model can be aware of the database but not the OS. (Anything deeper is probably irrelevant.)

I can intuitively grasp why this is a good idea but I can't articulate it. Why is this unidirectional style of layering a good idea?

答:
The most basic reason that the lower layers shouldn't be aware of the higher layers is that there are many more kinds of higher layers.  For instance, there are thousands and thousands of different programs on your Linux system, but they call the same C library malloc function.  So the dependency is from these programs to that library.

Note that "lower layers" are actually the middle layers.

Think about an application that communicates through the outside world through some device drivers. The operating system is in the middle.

The operating system does not depend on details within the applications, nor within the device drivers. There are many kinds of device driver of the same type and they share the same device driver framework. Sometimes kernel hackers have to put in some special case handling into the framework for the sake of a particular hardware or device (recent example I came across: PL2303-specific code in the usb-serial framework of Linux). When that happens, they usually put in comments about how much that sucks and should be removed.  Even though the OS calls functions in the drivers, the calls go through hooks that make the drivers look the same, whereas when drivers call the OS, they often use specific functions directly by name.

So, in some ways, the operating system is really a lower layer from the perspective of the application and from the perspective of the application: a kind of communication hub where things connect and data is switched to go the appropriate pathways. It helps the design of the communication hub to export a flexible service that can be used by anything, and not to move any device or application specific hacks into the hub.


问:
Ensuring that headers are explicitly included in CPP file
I think it's generally good practice to #include the header for any types used in a CPP file, regardless of what is already included via the HPP file. So I might #include <string> in both my HPP and CPP, for example, even though I could still compile if I skipped it in the CPP. This way I don't have to worry about whether my HPP used a forward declaration or not.

Are there any tools that can enforce this #include coding style? Should I enforce this coding style?

Since the preprocessor/compiler doesn't care whether the #include is coming from the HPP or CPP, I get no feedback if I forget to follow this style.

答:
If you need to enforce a rule that particular header files must stand on their own you can use the tools you already have. Create a basic makefile that compiles each header file individually but doesn't generate an object file. You will be able to specify which mode to compile the header file in (C or C++ mode) and verify that it can stand on it's own. You can make the reasonable assumption that the output does not contain any false positives, all required dependencies are declared and the output is accurate.

If you are using an IDE you may still be able to accomplish this without a makefile (depending on your IDE). Just create an additional project, add the header files you want to verify and change the settings to compile it as a C or C++ file. In MSVC for instance you would change the "Item Type" setting in "Configuration Properties->General".


问:
Why there is much more support for closed xls format in rails (and ruby) than to an open ods format?
It is little depressive, but it seems to me that there is much more support for manipulating ugly proprietary closed format like xls in rails (and ruby) in general that to documented open Open Document format. Why it is so? (I know it is kind of philosiophical, but I just do not get the fact, that the opensource is not more inclined to write SW for open formats).

For example for ruby there is a spreadsheet gem.

答:
Supply and demand.

Manipulating Excel spreadsheets is a task which is extremely useful to many people, hence there is considerable demand for code that does this, hence that code exists.

Manipulating ODS spreadsheets is useful only to a very tiny niche, hence there is minimal demand for code that does this, hence nobody has bothered to expend much effort writing that code.

If ODS ever becomes more than, say, 0.1% as widely used as XLS spreadsheets, this situation may change.


问:
Give advice from experienced to beginner programmer on reinventing my wheel(solution)
i ve just tried to do coding bat exercise. There are posted solutions to the problem i tried to solve.
However, I was stubborn, i ignored them and tried to code it up my own way(basically reinventing my own wheel - square,bad working wheel).
After 4 hours it looks nasty and fails some tests.

Now i realize that my logic was totally wrong and wasteful.
So the question :

When do you start to give up solving problem your own way(reinventing
the wheel) and start to look around to see other solution?

How long should a developer be 'stubborn' in trying to find his 'unique' or complicated solution?

When do you give up and begin to search for
another logic?

答: Frankly, I always look for an existing solution first, preferably more than one. Don't waste your time reinventing things that exist, unless none of the existing solutions meet your requirements (in which case, they aren't really solutions, are they?). </p>


问:
Describe the best deployment environment you've worked with
The Joel Test includes the question:

Can you make a build in one step?

Which is important, but I'm wondering, how streamlined have some of the deployment processes been?

All software from shrink-wrap to web applies: what's the best deployment environment you've worked with, and what steps were involved?

答:
We have a Java Web Start application - we are about to rebuild the deployment procedure to be as a WAR file with the JNLP file being adapted to the URL requested when requsted by the users.

I expect that to go extremely smooth.

Lately we have used git a lot.  The idea of registering deployments in git repositories so you can simply ask git to checkout the version you want to run.  Background updates, very short checkout time to update actual files, very short checkout time to roll back to a previous version in case of problems.  I think it could work very well for us.

ContentLicense: CC BY-SA 2.5


答:
You don't reinvent the wheel, unless you have valid reasons to do it.

If you are aware of the actual implementation, but believe you can do better (the second reason from the list), than you start by explaining to yourself what exactly you're imagining improve over the existent solution. Then,

Either you solve the problem,

Or you find yourself unable to solve it,

Or, which is, I imagine, your actual case, you discover that you can't clone the existent solution in the first place, before even trying to add your unique features or do things better.

In the last two cases, you simply check constantly your goals and your actual state.

Don't code just for the purpose of coding. Code with a goal in mind.

Don't spend hours writing untested and untestable code. Start by writing tests, then code itself.

Don't blindly try achieving an imprecise goal. Write, if need, the precise functional and non-functional requirements. Having the last ones is especially important. If you're reimplementing something, make sure you have enough non-functional requirements which control the performance of your solution compared to the one you clone, how well is it documented, how extensible is it, etc.

Gathering and writing those requirements, by the way, may push you into a deeper exploration of the solution you're cloning, which finally may lead you to the conclusion that your actual need is already solved by it, or that instead of reinventing everything, you may just extend the existent solution. Here's an example of both finding unknown features and extending the solution.

Finally, how long will you persist trying until you understand you're on a wrong way depends on your personality. I myself wasted four hours this Sunday trying to implement something in Python (while I never used Python before), to finally understand that I completely failed, and that the only reasonable way to do my job is to discard everything I've done for hours, and solve the business problem in a language I use daily for the last six years. Other people would have spent maybe a day. Others would have abandoned after an hour.

It also depends on the context. I really wanted to try something "real" in Python. If it was a language I don't have a good opinion, I would have abandoned after the first issue, blaming the language.

Title: Give advice from experienced to beginner programmer on reinventing my wheel(solution)

Body:
i ve just tried to do coding bat exercise. There are posted solutions to the problem i tried to solve.
However, I was stubborn, i ignored them and tried to code it up my own way(basically reinventing my own wheel - square,bad working wheel).
After 4 hours it looks nasty and fails some tests.

Now i realize that my logic was totally wrong and wasteful.
So the question :

When do you start to give up solving problem your own way(reinventing
the wheel) and start to look around to see other solution?

How long should a developer be 'stubborn' in trying to find his 'unique' or complicated solution?

When do you give up and begin to search for
another logic?


问:
Should I keep using the normal mysql_query or switch to PDO interface in php?
I'm building a big website, and using the normal old mysql_query method for transactions and communications with the database, and everything i going fine, including security. I'm a little bit confused, should I switch to the new PDO interface? cause I learnt that's safer, or keep using the old mysql_query() and mysql_fetch_assoc() methods?

I'm very close to completing the website, and to switch to the PDO interface will cost me time, to start updating my codes.

I'm a little confused, which should I use and what are the pros and cons?

答:
I'm a little confused, which should i use

No doubt if you just go through this link you will see a notice. So you should get switched to PDO or MySQLi.

Cons and Pros :

There are many posts available on stackoverflow on this subject. They all talk about PDO and why use it.

one

two

three

four

And many more here. Finally I would recommend you to switch to PDO or mysqli as mysql will be removed as per the link. Even if you have considered the security issues and secured you app, whats the use when it is completely lost? You need to do it later time somehow, So do it now itself. Hope this helps.


问:
CMS updates into subversion -> review process
We manage a range of client sites built in Wordpress and Joomla and these require regular updates to the core CMS and extensions. We keep these sites in subversion and place updates in subversion. We try to use a single revision for this.

We face some difficulties in making this process efficient, over time we would like to automate it, so we can offer the process on a fixed price basis

The process is currently as follows

make copy of whole folder

svn status |grep '^!' |sed 's/^!\s*/svn delete "/g' |sed 's/$/"/g' |sh

svn update

svn status |grep '^?' |sed 's/^?\s*/svn add "/g' |sed 's/$/"/g' |sh

svn ci -m "Commit message"

svn remove -m"temporarily remove" http://subversion.repository.com/svn/automatem/projects/client/trunk/project/foldername

Steps 5-6 are usually repeated multiple times.

What I'm looking for help with

we are using subversion version 1.6 and 1.7, because there are no .svn folders in 1.7 in subdirectories, I wonder if the process is much easier on 1.7?

we've added step 3 because it reduces the number of repeats in steps 5-6. However this was just trial and error and I can't quite get my head around why this is

As I understand it, the issue in step 5-6 is that when the an extension is updated, it may delete a whole folder and then re-insert that folder with changed files. In subversion 1.6, this would remove the .svn folder, which causes a 405 Access denied error (the folder gets added, but already exists in svn). What I would need is something that inserts all .svn folders back into my working copy if the folder already exists in svn. Is there a way to accomplish this?

Any other improvements of course appreciated.

答:
You forgot to mention some significant things:

Does sites (in core or|and in modules) have customer-specific changes or they use vanilla code?

Are clients sites also Working Copies of SVN-repos or unversioned trees?

Why (at least for WP, can't recall Joomla state for today) you don't use embedded updater, which can update all - core, modules, themes?

Anyway, your current process doesn't have any sense (for me). In order to update in your repository external code, also served by SCM, you can have a lot less operations

WP, no local modifications

Link your trunk (with externals) to latest tag of WP's core in WP-repository

Link all used in installation Wordpress plugins to latest tags of these plugins in WP-plugins repository (combine all external definitions in one common location for better manageability)

When new release of anything will appear, you have only:

Change external of this anything in order to link to new tag

Update tree (updates will appear in your WC automagically)

Commit changes and deploy new version of site to destination

WP, local modifications

For existing local changes workflow will be changed only in some details: your code will be in trunk, vendor's code - in some (RO) branches (also externaliz'ed), which you merge to trunk after update

Same tricks can be applied to Joomla, maybe just one-two more will be needed, when (if) Joomla will change SCM-backend from Subversion


答:
I would prefer PDO for any new development, as its a pretty nice interface and supports most backend databases without to much fiddling (with the notable exception of ORACLE!).

However if you a a functioning system using 'mysql_query' then I don't see any reason to change. The main advantage of PDO apart from portability is that its a nice clean interface to code up. But as your application is already coded and you do not intent to switch from MySql to another DB I think your time would be better spent doing something more useful.

Title: Should I keep using the normal mysql_query or switch to PDO interface in php?

Body:
I'm building a big website, and using the normal old mysql_query method for transactions and communications with the database, and everything i going fine, including security. I'm a little bit confused, should I switch to the new PDO interface? cause I learnt that's safer, or keep using the old mysql_query() and mysql_fetch_assoc() methods?

I'm very close to completing the website, and to switch to the PDO interface will cost me time, to start updating my codes.

I'm a little confused, which should I use and what are the pros and cons?


问:
How to make support for bindings for a scripting language

Main

I'm making a scripting language using C++. I plan to use it with a simple test game editor. But I have to make a support for bindings to call game engine's nodes' methods to update positions, rotations, etc.

What are the main approaches for this?

The game engine I plan to use also supports lua, so maybe I can also use this fact.

Details

The problem I have faced lies in the fact of how can I call library C++ object methods within a script. English is not my native language and the lack of knowledge in that sphere prevents me from making a good query on the topic. So I don't know what to search. Google shows me information on how to make bindings to some scripting languages not the fundamentals by search phrases like "how to make bindings support to a scripting language", "scripting bindings".

At this time I came up to the following things. I have to inherit all objects that will be used in script from a service class, ex. CLangObject. With its help I can identify the object's type within a C++ library objects' methods. Then I have to define the most general pointer to method types. I have also define a callback service class to pass it to a byte machine when C++ library method returns value. The game engine I want to use has bindning to lua, so maybe I can use its LuaObject and LuaCallback classes. At this time I don't know if this approach will lead to a normal result.

答:
I think the better search term for this might be "bridge", have a try with that.

The simplest approach is to use a C function to dispatch from the scripting language into your engine. Imagine a function msgSend(target, message, arg0, ...); if you can write the scripting language engine such that it can call msgSend with arbitrary arguments, you can see how from that you can call target's message method with arg0, ....

Since you mention Lua, have a look at https://github.com/vinniefalco/LuaBridge . You can see in the sample how he passes in classes and function addresses -- on the Lua end these will be wrapped as some kind of Lua object and calling that function will enter a message dispatch function that will unwrap the target and arguments (if necessary) and proceed to call the function from the address.


问:
In MVC is it considered good practice to have private, non-action, functions in a controller class?
Sometimes action functions in the controller class can become huge and nasty, with many-many lines of code to simply control the flow of data from the Model to the View. At some point these huge functions completely lose track of the basic principles of good code, i.e. only doing one thing, being small, readable and manageable etc.

Would it be considered good practice to break these huge action functions into smaller private functions in the controller class or should the need of such optimization mean we should rather add them in the model?

I would vote for having the smaller functions as private in the controller so that they are relative to the action, but I have heard arguments that the controller should preferably be simple while the model can get huge and clumpy; and was just wondering which one would be the most preferred method.

答:
Might not be the best analogy but, think about the controller the same way as you would think about a spider's web. Its sole job is to catch flies (requests) for the spider (underlying layers) to digest. The web can catch and hold smaller or larger flies (models). A spider's web role is not to digest the prey, although it can be used in this purpose. The thinner and cleaner the web, the easier for the spider to make a living.

You could apply somewhat the same logic to your MVC application. The huge and nasty functions you describe are most likely behavior of the model and they should belong in the model (note that the model is not only the object that's being displayed in the view). If the behavior of the model changes it's the model that should be changed and not the controller that handles it.

Also, keeping them as private methods in the controller would only clutter it and make it hard to maintain. It also makes way for a bad habit, since other people that are involved in development would be tempted to do the same, since they've seen it done before in the project.


问:
How to avoid code duplication across unrelated projects
I'm a contractor at a large Telco where I'm usually working on several different projects at once.

The VCSs I use (mainly git and mercurial) tend to make me keep the code bases for unrelated projects in separate repositories, and I realise many benefits of this approach.

However, there are many little bits of utility code and helper functions I've written which are useful across two or more projects, and I'm well aware of the benefits of keeping my code DRY - for example sometimes I find a better way to implement some piece of code and I don't want to have to update it in every place where I've duplicated the same idea.

What is the best way to refactor out this common functionality (it is not always so simple as copy-and-paste, but sometimes it is..) without creating unnecessary dependencies between unrelated projects, and without adding needless complexity?

答: Factor the common stuff out into one or more libraries. Put the library in its own repo, and in the individual projects, add a bit of logic to your build script to make sure you have the correct version of the library. You may or may not fancy subrepos for this; matter of taste, really.</p>


答:
Normally it's good to use the Mysqli or PDO is the best option for connecting database, since mysql will be removed soon.

But in developer point of view, write a simple wrapper class for all database connectivity

For example

For mysql

```<code>Class database_mysql {
     public getResults($query) {
         $result = mysql_query($query);
         $row = mysql_fetch_assoc($result);
         return $row;
      }
.
.
.
<other functions>
}
</code>```

For PDO

```<code>Class database_pdo {
     public getResults($query) {
        $statement = $pdo->query($query);
        $row = $statement->fetch(PDO::FETCH_ASSOC);
        return $row;
      }
.
.
.
<other functions>
}
</code>```

For mysqli

```<code>Class database_mysqli {
     public getResults($query) {
        $result = $mysqli->query($query);
        $row = $result->fetch_assoc();
        return $row;
      }
.
.
.
<other functions>
}
</code>```

when you initialize the class use below

```<code>$db = new Database_mysql(<arguments>);
</code>```

where ever you need the results, just use

```<code>$db->getResults(<query>);
</code>```

if you need to switch over to mysqli, or PDO, just change the class name

```<code>$db = new Database_pdo(<arguments>);
</code>```

So this will save lot of your time on changing the extension.

Body:
Normally it's good to use the Mysqli or PDO is the best option for connecting database, since mysql will be removed soon.

But in developer point of view, write a simple wrapper class for all database connectivity

For example

For mysql

Class database_mysql {
     public getResults($query) {
         $result = mysql_query($query);
         $row = mysql_fetch_assoc($result);
         return $row;
      }
.
.
.
<other functions>
}

For PDO

Class database_pdo {
     public getResults($query) {
        $statement = $pdo->query($query);
        $row = $statement->fetch(PDO::FETCH_ASSOC);
        return $row;
      }
.
.
.
<other functions>
}

For mysqli

Class database_mysqli {
     public getResults($query) {
        $result = $mysqli->query($query);
        $row = $result->fetch_assoc();
        return $row;
      }
.
.
.
<other functions>
}

when you initialize the class use below

$db = new Database_mysql(<arguments>);

where ever you need the results, just use

$db->getResults(<query>);

if you need to switch over to mysqli, or PDO, just change the class name

$db = new Database_pdo(<arguments>);

So this will save lot of your time on changing the extension.


问:
Is it advisable to ask employees to create 'work' GitHub accounts?
I've moved all our company Git repositories to GitHub and now I want to add employees to the projects. Since most employees already have personal GitHub accounts, I'm wondering whether I should ask them to create a work GitHub account. The reason that I'm thinking of doing this is to decrease the chances of unauthorized access to our code base since their personal accounts may be well publicized through their personal activity on the site, increasing chances of targeted attacks. Furthermore, if their personal account is ever compromised it won't mean the whole company code is accessible to the hijacker. Since this will bring the burden of maintaining two accounts for the employees I'm wondering whether it is the correct approach and whether it even makes sense. I would love to hear your opinions on this.

Update
Thanks for all the useful insights. I won't set an answer as accepted because of the subjective nature of the question/answers and since I took the best points from several different answers.

I have decided to go forward this way: I will remind employees that work-related GitHub e-mail notifications will have to be sent to their work e-mail accounts for practical reasons. Therefore it would make more sense to create work GitHub accounts. If they are willing to use their personal GitHub accounts and connect it to their work e-mail accounts then that's fine. In any case, employees will have to agree in written form to a number  of conditions tied to using GitHub. These are related to account security: choosing a secure password using a secure random password generator that is not used with any other account, not accessing GitHub through computers not owned or administered by them, etc. At the end of the day employees will have to decide themselves whether a work account makes more sense for them or not.

答:
We are doing it in our company. I don't want to start a discussion "what is safer, github or a server under your table that everyone has root access, not sure if the backup is working, etc". Our approach was:

every developer, must create a new account, unrelated with his personal github account

it should use the company email.

It should be compliant with our security rules (login name and password requirement).

They cannot show/have any public activity.

It's company property. Not his/her account.

All accounts are connected with a company, random name as well. No public activity as well.


答:
Well, "little bits of utility code" are probably best not shared across unrelated projects.  Just look at how many implementations of "Hello, World!" are out there. :-)

Seriously, DRY is not an absolute.  There is a cost for searching for an existing solution and a relatively high maintenance cost for sharing library code across otherwise independent projects.  One project wants to add functionality but another project doesn't, so what do you do? You fork it or add an option, and now you're not really sharing the code anymore.  Or worse one project adds a feature but it breaks some other project. The more people use a library the harder it is to change.

You see a very big and practical example of this right now in the Ruby on Rails community.  Projects rely on dozens of gems (hefty bits of utility code) and then they are afraid to update them because something will break because "improvements" in one library break the expectations of another.  It's managed to a large degree with sensible version numbers that segregate changes by the likelihood of breaking existing code, but still, there's a lot of overhead to versioning and managing those version numbers, and it's just not worth it for 20 lines of code.

As a rule of thumb, if you're the first person to write it, it's not that useful.  If Large Telco doesn't already have that functionality in the codebase such then no one else felt it was important.  More likely, it's in there somewhere and you can't be bothered to find it because it's easier to just write it yourself.  And you're probably right, but so are your colleagues who want to just write it themselves rather than go look for it.

In practice, the best advice I can give is to keep your own personal library of code snippets and carry them around with you.  Copy and paste from other projects if you like.  As long as the snippets are small and don't contain real secrets, like cryptographic keys or the formula for Coca-Cola, no one is going to bother you about taking code from one company to another let alone from one project to another.

And then when a colleague asks "hey, do you know a good way to do X" you can just copy and paste the code into an email or IM and be the hero of the hour.

Title: How to avoid code duplication across unrelated projects

Body:
I'm a contractor at a large Telco where I'm usually working on several different projects at once.

The VCSs I use (mainly git and mercurial) tend to make me keep the code bases for unrelated projects in separate repositories, and I realise many benefits of this approach.

However, there are many little bits of utility code and helper functions I've written which are useful across two or more projects, and I'm well aware of the benefits of keeping my code DRY - for example sometimes I find a better way to implement some piece of code and I don't want to have to update it in every place where I've duplicated the same idea.

What is the best way to refactor out this common functionality (it is not always so simple as copy-and-paste, but sometimes it is..) without creating unnecessary dependencies between unrelated projects, and without adding needless complexity?


答:
I usually follow below methodology when it comes to scenarios that you are facing:

Get the root cause of problem for the solution that you are developing, it is not necessary that all your code logic is waste if the solution is not achieved. If you properly get the root cause then you are able to think on the new logic that can be plugged in to overcome root cause else at this position you can search online for help on that particular root cause. This way you will narrow down your searching & it will be manageable.

Time to struggle for the solution really depends on two factors - deadlines if any And if no deadlines then till you get saturated. Usually time of around one day for a genuine issue is good enough to start re-thinking on some other approach. There are some instances where even after searching a lot on some particular problem there is no suitable solution found at that time the problem resolution may take up to a week also wherein you have to spend time on thinking out of the box solutions which have been never faced by anyone else till now. For example solving the issue of memory leakage from a Java 3D applet hosted on tomcat using web start.

I guess above points covers answers to your 3 questions to some extends.


问:
Migrating Web based projects from Java to PHP
At our work place after hours of coding, testing and QA we have successfully added a couple of software tools in our product line. We specialize in web based software solutions so in order to tap on more users we are now considering putting our developed solutions online for hosting and providing online access to all our clients for their products.

But what is coming in our way is that we have developed all these solutions in Java and compared to PHP Java hosting is very expensive. So we are now planing to migrate all these solutions to PHP while also maintaining their Java counterpart.

How we should start with these migration task?

We used AJAX in all our Java based solutions. Tech specs are

Front end web pages in JSP

Back end server side in Java using Apache Struts2

Database in MySQL

PDF report generation using iText PDF lib. for Java

NB: We have started a little with Code Igniter Framework in PHP.

答:
1) First and foremost understand this is not an easier way to approach any problem. PHP has a bad reputation for being nasty and tangled but I feel it has been made that way over the years because of its leniency. It is very easy to get lost in that "damn it's so easy" mentality and lose hold of your standards.

2) Read accepted and respected standards from the developers that drive both PHP, and the community. Fig is a good place to start (http://www.php-fig.org/)

3) Frameworks come in all flavors, pick the one that is both attractive in terms of features and appropriate for your companies needs. CodeIgniter is a start but explore CakePHP or Laravel if you fancy Rails, Zend or Symfony if you want to slap that "enterprise" sticker on there for your boss, and finally if you find those to be cumbersome it couldn't hurt to look at something like Slim. In the end there are literally thousands of frameworks, find the one you feel both comfortable with using and will scale for your businesses needs. The list I provided is short, you should be able to find more on your own with no trouble.

4) Don't be afraid to try new things. CodeIgniter is loved for being lightweight and powerful, however it also is the easiest option in most cases. CodeIgniter simplifies some aspects of your workflow, but forces you to look at the MVC paradigm in a certain way and transitioning after spending time with CodeIgniter to something else can be difficult.


问:
Is it possible to shuffle team in between a sprint?
We are working on scrum framework. Now a situation arise that we have to shuffle 2-3 scrum team members in between sprints.

Is it possible to shuffle sprint team members in between a sprint?  What are the potential drawbacks of doing this?

答:
One of the core concepts of Scrum Agile is timeboxing and that means basically a fixed period of time for what I call focused activity. This focused activity would at it's base be the sprint you are in.

Given that, I always found the biggest drawback is a loss of focus when changing sprint team members during a sprint. The loss of focus means a loss of work and team velocity. The only times I have done this where it worked was because of a particularly bad team member or an emergency situation where a team member was out sick but the work they were on that sprint was higher priority than other teams.

What is more interesting as a question is to ask "why" you are considering moving team members around. Usually this is an indicator of a bigger problem and, as you mentioned, a situation as risen. If you must move team members around note the loss of focus which also means a loss of work and try to solve for the problem that came up initially to prevent it from happening again.


问:
The best way of coding web system in term of performance
So far I've been using IPB and my custom scripts all coded in PHP but I am really disappointed of the long term performance of it.

I would like to move to native coding, the learning time to put into doesn't matter at all.
Ive found CppCMS and it seems to be the exact solution i was searching for.

I would like to know from anyone who has chosen this way, what have you done?
Is CppCMS the best one in term of performance?

If yes, with what webserver should I run it with and any special configuration?

I am really searching for the best way to go in term of performance (learning time and coding time does not matter).

答: CppCMS is a good solution, but another one to look at is Microsoft's Casablanca which is designed for very efficient (and fast) performance for the cloud. Note that is offers a lot of web-style tooling but it is not a "website framework" for easily writing a website, more about writing webservices and REST APIs.</p>


问:
Exploratory Development vs Incremental Development
In Software Engineering Methodologies... The Evolutionary Development contains Exploratory & Prototyping...
Is Exploratory Development same as Incremental Development... What do you mean by exploratory Development?

The terms are taken from
Software Engineering - Ian Sommerville

答:
Exploratory development, to me, means trying out new development technologies or infrastructure solutions.

It could also mean building new functionality from scratch, or as part of an existing system. Maybe you've been asked to look at how something might work, before getting official go ahead for a bigger piece of work.

Incremental development is about progressively working your way through the development life cycle, usually meaning short development time periods, releasing more often etc.


答:
Performance problems with web applications rarely are caused by the choice of language. More typically they are caused in faulty architecture design.

While PHP is the slowest performing in web app development, and it's a mess of a language, there are plenty examples of very high traffic web sites using PHP.

You also say that:

learning time and coding time does not matter.

It does. If you have fixed deadline, each hour you have to spend on mundane coding is each hour less spent on architecture design, testing etc.

Title: The best way of coding web system in term of performance

Body:
So far I've been using IPB and my custom scripts all coded in PHP but I am really disappointed of the long term performance of it.

I would like to move to native coding, the learning time to put into doesn't matter at all.
Ive found CppCMS and it seems to be the exact solution i was searching for.

I would like to know from anyone who has chosen this way, what have you done?
Is CppCMS the best one in term of performance?

If yes, with what webserver should I run it with and any special configuration?

I am really searching for the best way to go in term of performance (learning time and coding time does not matter).


答:
Well, the simple answer is, yes it's possible, but there is a good chance doing so will affect the completion of the sprints tasks.

It depends on the reason for the changes however.

If some outside factor (absence, employee leaving company/project at short notice etc), then there is only so much you can do to mitigate this.

If it is a re-prioritization of tasks mid-sprint, ideally you don't want this to happen mid-sprint, but with agile, you are supposed to be able to deal with this a little better, although it's not ideal.

Title: Is it possible to shuffle team in between a sprint?

Body:
We are working on scrum framework. Now a situation arise that we have to shuffle 2-3 scrum team members in between sprints.

Is it possible to shuffle sprint team members in between a sprint?  What are the potential drawbacks of doing this?


答:
Is it possible to shuffle sprint team members in between a sprint?

Of course it is possible!!  You should never be so subservient to a methodology that you allow it to stop you doing things that you know that you need to do.

What are the potential drawbacks of doing this?

The obvious drawback is that the people who are moved around end up working on a different part of the problem.  They may need to acquire the domain and technology-base knowledge they didn't need to have before the shuffle.  They will definitely need to acquire understanding of parts of the codebase that they didn't previously.  These overheads will tend to make reduce "agility" ... in the normal sense of that word.

But if there is an overwhelming reason to shuffle the team, you may just have to wear that (hypothetical) loss of efficiency / agility.  If you have people who can't cope with certain tasks, or can't work together, a well executed shuffle could get back that lost efficiency ... and some more.


问:
Should a complex unifying class be doing computation?
I have a large application in Java filled with independent classes which are unified in a PlayerCharacter class. The class is intended to hold a character's data for a game called the Burning Wheel, and as a result, is unusually complex. The data in the class needs to have computations controlled by the UI, but needs to do so in particular ways for each of the objects in the class.

There are 19 objects in the class PlayerCharacter. I've thought about condensing it down, but I'm pretty sure this wouldn't work anywhere in the application as it stands so far.

```<code>private String name = ""; private String concept = "";
private String race = ""; private int age = -1;

private ArrayList<CharacterLifepath> lifepaths = new ArrayList<>();

private StatSet stats = new StatSet();
private ArrayList<Affiliation> affiliations = new ArrayList<>();
private ArrayList<Contact> contacts = new ArrayList<>();
private ArrayList<Reputation> reputations = new ArrayList<>();
//10 more lines of declarations
</code>```

I've been considering this problem for some time now, and have considered multiple
approaches. The problem arises primarily when data is deleted - for instance, since pretty much everything else (but not some parts!) depends upon Lifepaths, when a lifepath is deleted, nearly everything else must be recalculated. However, if a Skill is deleted, only a few things must be recalculated.

Additionally, the application must somewhere track certain values; skill points, trait points, etc. to ensure that the user is not unintentionally exceeding those values.

So my question is generally as follows: Where  should everything go? What makes this easiest? There are a couple options:

Place point total calculations in the PlayerCharacter class (but how does this generate a warning?)

Handle all calculation outside of the PlayerCharacter class, and just use PlayerCharacter as a container for all the character's information

Place all calculations in the PlayerCharacter class; after each item is changed, recompute the entire character. Then, if there are issues arising from deletion, throw warnings back at the UI.

I'm slightly overwhelmed by the scope of this particular class - whereas everything I've done so far has been easily broken down into small manageable chunks, this beast seems to resist being tamed. If there's a better approach to this, I'm all ears! But as of right now, I'm slightly confused, and progressing aimlessly probably won't get me anywhere. Any advice is appreciated.

I apologize if this is unclear - I'm certain I lack the software vocabulary to properly communicate my ideas. I would love to improve this question - any help here is appreciated!

答:
Separate interface from implementation. "PlayerCharacter" should be an interface with methods like "getStats", "getContacts", "getReputation" etc. This gives you freedom to play with the implementation without having to change the code which uses this interface.

The implementation can choose to cache values and recompute them if necessary. For example a method "getStats" would return the value of "stats" variable; and if the variable is empty, it would be recomputed first. Methods like "removeLifepath" could remove all cached lifepath-related values.

The methods for actual recomputation could be placed to yet another class, if needed. Thus you would have: A) the interface, B) one or more classes doing the calculation, and C) an implementation keeping the cached values, and calling recalculation when necessary.

Quick sketch:

```<code>interface PlayerCharacter {

    List<Lifepath> getLifepaths();

    void addLifepath(Lifepath lifepath);

    void removeLifepath(Lifepath lifepath);

    Skills getSkills();

}

class PlayerCharacterImpl {

    List<Lifepath> lifepaths = new ArrayList<>();
    Skills cachedSkills = null;

    public List<Lifepath> getLifepaths() {
        return Collections.unmodifiableList(lifepaths);
    }

    public void addLifepath(Lifepath lifepath) {
        lifepaths.add(lifepath);
        cachedSkills = null;
    }

    public void removeLifepath(Lifepath lifepath) {
        lifepaths.remove(lifepath);
        cachedSkills = null;
    }

    // thread-unsafe
    public Skills getSkills() {
        if (null == skills) {
            skills = PlayerCharacterCalc.calculateSkills(lifepaths);
        }
        return skills
    }

}

class PlayerCharacterCalc {

    static Skills calculateSkills(List<Lifepath> lifepaths) {
        Skills skills = new Skills();
        for (Lifepath lifepath : lifepaths) {
            skills.apply(lifepath);
        }
        return skills;
    }

}
</code>```

Body:
Separate interface from implementation. "PlayerCharacter" should be an interface with methods like "getStats", "getContacts", "getReputation" etc. This gives you freedom to play with the implementation without having to change the code which uses this interface.

The implementation can choose to cache values and recompute them if necessary. For example a method "getStats" would return the value of "stats" variable; and if the variable is empty, it would be recomputed first. Methods like "removeLifepath" could remove all cached lifepath-related values.

The methods for actual recomputation could be placed to yet another class, if needed. Thus you would have: A) the interface, B) one or more classes doing the calculation, and C) an implementation keeping the cached values, and calling recalculation when necessary.

Quick sketch:

interface PlayerCharacter {

    List<Lifepath> getLifepaths();

    void addLifepath(Lifepath lifepath);

    void removeLifepath(Lifepath lifepath);

    Skills getSkills();

}

class PlayerCharacterImpl {

    List<Lifepath> lifepaths = new ArrayList<>();
    Skills cachedSkills = null;

    public List<Lifepath> getLifepaths() {
        return Collections.unmodifiableList(lifepaths);
    }

    public void addLifepath(Lifepath lifepath) {
        lifepaths.add(lifepath);
        cachedSkills = null;
    }

    public void removeLifepath(Lifepath lifepath) {
        lifepaths.remove(lifepath);
        cachedSkills = null;
    }

    // thread-unsafe
    public Skills getSkills() {
        if (null == skills) {
            skills = PlayerCharacterCalc.calculateSkills(lifepaths);
        }
        return skills
    }

}

class PlayerCharacterCalc {

    static Skills calculateSkills(List<Lifepath> lifepaths) {
        Skills skills = new Skills();
        for (Lifepath lifepath : lifepaths) {
            skills.apply(lifepath);
        }
        return skills;
    }

}


问:
mvc pattern on procedural php
First off, I do not have anything against OO programming (I'd be mad if i believed so). But I was thinking on some sort of procedural MVC pattern with PHP; let me explain better.

As we all know, variable scopes, unless they are taken from $_SESSION (, database, redis, etc.) are never global and only refer to a singular execution of a script. For example:

```<code>class Car {
  this->name = "foo";
  function setName($name) { ... }
  function getName() { return $this->name; }
}
</code>```

Where obviously in a more common situation, this data will be taken from the DB, otherwise any object car, per execution, would have the same name.

Now, is it not possible to apply MVC pattern on procedural code for simplicity purpose? Imagine a really simple social network like application; I could have a structure like this

```<code>*views
  -profileview.php
  -messageview.php
  -loginview.php
  -notloggedin.php
*models
  -user.php
  -message.php
- profile.php
- messages.php
- login.php
</code>```

where profile, messages and login.php work as controllers and route to the right view; and user and message.php work as the classes, that contain all the functions that are eventually needed by the controllers, such as getUserById($id), postMessage($id, $meesage), etc.

I have simplified it a lot but I think you can sort of understand my point.

What would you think of such implementation on the long run, and why?

答:
There is no benefit to doing it this way, there is only pain and suffering. The MVC paradigm was largely invented to move away from doing it in a linear one-way-street fashion. What you'll wind up with is a tangled mess that fast approaches zero flexibility as you add to it over time.

If you're making your own framework, consider:

Having a front-controller

Representing the request as a singleton

Representing controllers as singletons

Delegating work to subcontrollers

Have your controllers return a View back up the call chain, allowing each controller to modify (or replace) it.

This strategy will grant you some mega flexibility with very little code.

The following is a very basic proof of concept. You would obviously want to flesh out the controllers to account for 404's, sanitize $_SERVER['REQUEST_URI'], etc.

```<code>abstract class Request {
    public $tokens;
    final private function __construct() { } // static singleton
}

abstract class View {
    abstract function render();
}

class MyView extends View {
    function render() {
        echo 'Hello, world.';
    }
}

class MyTheme extends View {
    public $content; // nested View
    function render() {
        echo '<h1>Themed</h1>';
        $this->content->render();
    }
}

abstract class Controller {
    final private function __construct() { } // static singleton
    abstract static function route(); // inspect the request and handle it locally,
                               // or send it to a subcontroller
}

abstract class FrontController extends Controller {
    static function route() {
        // inspect current(Request::$tokens) and decide to send it elsewhere
        next(Request::$tokens);
        $themed = new MyTheme();
        $themed->content = MySubController::route();
        return $themed;
    }
}

abstract class MySubController extends Controller {
    static function route() {
        return new MyView();
    }
}

/* in the script that invokes your front controller */
Request::$tokens = explode('/',$_SERVER['REQUEST_URI']);
FrontController::route()->render();
</code>```

Title: mvc pattern on procedural php

Body:
There is no benefit to doing it this way, there is only pain and suffering. The MVC paradigm was largely invented to move away from doing it in a linear one-way-street fashion. What you'll wind up with is a tangled mess that fast approaches zero flexibility as you add to it over time.

If you're making your own framework, consider:

Having a front-controller

Representing the request as a singleton

Representing controllers as singletons

Delegating work to subcontrollers

Have your controllers return a View back up the call chain, allowing each controller to modify (or replace) it.

This strategy will grant you some mega flexibility with very little code.

The following is a very basic proof of concept. You would obviously want to flesh out the controllers to account for 404's, sanitize $_SERVER['REQUEST_URI'], etc.

abstract class Request {
    public $tokens;
    final private function __construct() { } // static singleton
}

abstract class View {
    abstract function render();
}

class MyView extends View {
    function render() {
        echo 'Hello, world.';
    }
}

class MyTheme extends View {
    public $content; // nested View
    function render() {
        echo '<h1>Themed</h1>';
        $this->content->render();
    }
}

abstract class Controller {
    final private function __construct() { } // static singleton
    abstract static function route(); // inspect the request and handle it locally,
                               // or send it to a subcontroller
}

abstract class FrontController extends Controller {
    static function route() {
        // inspect current(Request::$tokens) and decide to send it elsewhere
        next(Request::$tokens);
        $themed = new MyTheme();
        $themed->content = MySubController::route();
        return $themed;
    }
}

abstract class MySubController extends Controller {
    static function route() {
        return new MyView();
    }
}

/* in the script that invokes your front controller */
Request::$tokens = explode('/',$_SERVER['REQUEST_URI']);
FrontController::route()->render();


答:
This will be a partial answer since I'm not a regular user of Java (more of a C++ guy myself).
Here's a few ideas that could guide you :

1) If a attribute may be edited by multiple sources (a Stat calculated with a base value, bonus/malus from a skill and bonus from multiple lifepath), perhaps should you not save it as a single value, but as a association of value; and it could be used to limit the total value if you wand to be sure it will not leave some boundaries. For example, something like that :

```<code>public class StatModifier {
  public String source; // the 'editing' source (ex : a lifepath)
  public String target; // the edited Stat (ex : strength)
  public int modifier;
}

public class Stat {
  private int base;
  private ArrayList<StatModifier> modifiers;
  private int computedValue;
  private int actualValue;
  private bool computed;

  public function addModifier(modifier) { // removeModifier() is basically the same
    modifiers.add(modifier);
    computed = false;
  }
  public function getValue() {
    if (!computed) {
      computedValue = base;
      // TODO : here compute value (ex : sum modifiers)

      actualValue = Math.min(computedValue, 100); // Max stat value : 100
      computed = true;
    }
    return actualValue;
  }
}
</code>```

If you use this method, then the modifications of a Lifepath is a list of modifiers, and when you add/remove a lifepath, you just have to add/remove the associated modifiers. Those modifiers would logically be present within the Lifepath instance, and the PlayerCharacter class will only have to get this list and process it.

2) if you need to limit the total value of a group (say, a character cannot have more than 50 skill points across all skills), you could use a SkillSet class (for exemple) who would work as a list of skills and a validator. That way, the PlayerCharacter class only have to request the validate() method of all these class to be sure that the character is valid, and the actual validation rules will be managed set by set.

3) keep a list of the modification done since the last validation. That way, if you detect that the user is not valid, you can rollback them.

4) if you use '1)', a validation step could also be to check that the sources of each modifier (still) exists.

Title: Should a complex unifying class be doing computation?

Body:
I have a large application in Java filled with independent classes which are unified in a PlayerCharacter class. The class is intended to hold a character's data for a game called the Burning Wheel, and as a result, is unusually complex. The data in the class needs to have computations controlled by the UI, but needs to do so in particular ways for each of the objects in the class.

There are 19 objects in the class PlayerCharacter. I've thought about condensing it down, but I'm pretty sure this wouldn't work anywhere in the application as it stands so far.

```<code>private String name = ""; private String concept = "";
private String race = ""; private int age = -1;

private ArrayList<CharacterLifepath> lifepaths = new ArrayList<>();

private StatSet stats = new StatSet();
private ArrayList<Affiliation> affiliations = new ArrayList<>();
private ArrayList<Contact> contacts = new ArrayList<>();
private ArrayList<Reputation> reputations = new ArrayList<>();
//10 more lines of declarations
</code>```

I've been considering this problem for some time now, and have considered multiple
approaches. The problem arises primarily when data is deleted - for instance, since pretty much everything else (but not some parts!) depends upon Lifepaths, when a lifepath is deleted, nearly everything else must be recalculated. However, if a Skill is deleted, only a few things must be recalculated.

Additionally, the application must somewhere track certain values; skill points, trait points, etc. to ensure that the user is not unintentionally exceeding those values.

So my question is generally as follows: Where  should everything go? What makes this easiest? There are a couple options:

Place point total calculations in the PlayerCharacter class (but how does this generate a warning?)

Handle all calculation outside of the PlayerCharacter class, and just use PlayerCharacter as a container for all the character's information

Place all calculations in the PlayerCharacter class; after each item is changed, recompute the entire character. Then, if there are issues arising from deletion, throw warnings back at the UI.

I'm slightly overwhelmed by the scope of this particular class - whereas everything I've done so far has been easily broken down into small manageable chunks, this beast seems to resist being tamed. If there's a better approach to this, I'm all ears! But as of right now, I'm slightly confused, and progressing aimlessly probably won't get me anywhere. Any advice is appreciated.

I apologize if this is unclear - I'm certain I lack the software vocabulary to properly communicate my ideas. I would love to improve this question - any help here is appreciated!

Body:
This will be a partial answer since I'm not a regular user of Java (more of a C++ guy myself).
Here's a few ideas that could guide you :

1) If a attribute may be edited by multiple sources (a Stat calculated with a base value, bonus/malus from a skill and bonus from multiple lifepath), perhaps should you not save it as a single value, but as a association of value; and it could be used to limit the total value if you wand to be sure it will not leave some boundaries. For example, something like that :

public class StatModifier {
  public String source; // the 'editing' source (ex : a lifepath)
  public String target; // the edited Stat (ex : strength)
  public int modifier;
}

public class Stat {
  private int base;
  private ArrayList<StatModifier> modifiers;
  private int computedValue;
  private int actualValue;
  private bool computed;

  public function addModifier(modifier) { // removeModifier() is basically the same
    modifiers.add(modifier);
    computed = false;
  }
  public function getValue() {
    if (!computed) {
      computedValue = base;
      // TODO : here compute value (ex : sum modifiers)

      actualValue = Math.min(computedValue, 100); // Max stat value : 100
      computed = true;
    }
    return actualValue;
  }
}

If you use this method, then the modifications of a Lifepath is a list of modifiers, and when you add/remove a lifepath, you just have to add/remove the associated modifiers. Those modifiers would logically be present within the Lifepath instance, and the PlayerCharacter class will only have to get this list and process it.

2) if you need to limit the total value of a group (say, a character cannot have more than 50 skill points across all skills), you could use a SkillSet class (for exemple) who would work as a list of skills and a validator. That way, the PlayerCharacter class only have to request the validate() method of all these class to be sure that the character is valid, and the actual validation rules will be managed set by set.

3) keep a list of the modification done since the last validation. That way, if you detect that the user is not valid, you can rollback them.

4) if you use '1)', a validation step could also be to check that the sources of each modifier (still) exists.


问:
How to find method and class usages along git repositories
We got some code in a git repository that's used along different projects (with git different repositories), the problem is that we got now so many different projects that's difficult to track which projects will be affected and how when there is a change in the shared module.

Is there any way to find classes and methods usages along different git repositories? Or who would you manage an architecture like that?

答:
Take a look at some code quality and code indexing tools.

FishEye

For starters, you could use FishEye, which would index your code and allow you to quickly query for code from all the repositories so you can keep a bird's eye view of the whole codebase.

For instance, you could search for a given file (but also for a file's content, including a method name) and it will find affiliated tickets and changesets that modified it, and its latest version in your code repositories:

However, FishEye doesn't necessarily understand the code and see methods as units to be tracked, so you can't say "find call points of method M of class C".

Sonar

A code quality tool like Sonar would also allow you to keep an eye on dependencies (especially if you have a maven-based build).

For instance, a very handy view is this one:

It allows you to see the connections between different components in terms of dependencies, so you know that a change to this component might impact the other ones.

Read here for more.

Again, it doesn't really tell you that at the method level though (it relies on the dependency graph of the binary dependencies of your build).

Update: Actually, looks like Sonar even does method level tracking (see the SonarSource blog I linked above):

Krugle

Available online for open-source project repositories, you can also deploy your own instance (basic version for free).

http://www.krugle.org/

CodeSight

Host your own CodeSight instance.

http://www.blackducksoftware.com/products/code-sight

Elastic Search

GitHub uses it since January 2013, so if your git repo is GitHub-hosted you can already benefit from that. Otherwise you can roll out your own.

Roll Out Your Own

Probably not adviseable, but you could probably produce an indexed database of your code using a nightly job parsing your projects and using a full-text search engine (like Apache Lucene, for instance), or even something more low-tech than that.

You can find more tooling support for code analysis and graphing at the class level, but you'd end up with pretty complicated and unreadable graphs very quickly anyways, for any relatively large system.

Many build systems have plugins for that sort of thing.


答:
For me the school of thought is often "This is an obvious problem therefore someone must have encountered it before and given a solution or steps towards it"  be it a plugin or a snippet class or whatever.

There is merit in trying to tackle it yourself and think through the problem but, if time is a factor why not take advantage of collective wisdom.

I would add that if using a code snippet or class it is always worth reading the associated tutorial and the code so that you understand the solution.

One of the benefits of that first step of thought time is to help focus you on what the problem actually is, what the requirements really are and therefore what you need in the solution.


问:
Integration test instead of unit test involving personal data?
I am trying to develop a series of unit tests for a production system that are dependent on a person's social security number. While I am more than comfortable hard coding a clearly bad social security number to test for failure, I'm uneasy about including one that is good for proper (and passing) results. The following is a simplified test that I'm using:

```<code>[TestMethod]
    public void API_Hours_Get()
    {
        var controller = new HoursController();
        var employee = new EmployeeController();
        var badResult = controller.Get(123124569);
        var goodResult = controller.Get(employee.GetEmployeeByUserId("Username").First().SSNumber);
        Assert.IsFalse(badResult.Any());
        Assert.IsTrue(goodResult.Any());
    }
</code>```

This test passes just fine and gives me the results I want. But, from my understanding, it is an integration test. From a best practices perspective, is this substitute okay for my test suite and just ignore the fact that I don't have a 'pure' unit test for the SSN-dependent modules or is there a better approach for situations like this?

答:
If you are injecting a repository then you can write tests to your hearts content without worrying about whether the data is real.   </p>

<p>Remember what it is you are testing!
You are testing an atomic unit of functionality.  Whether the SSN is real doesn't matter, it's whether the method you are testing handles it correctly.  i.e  will it reject one with too many/too few digits,  will it reject a null entry etc.. </p>

ContentLicense: CC BY-SA 4.0

Body:
If you are injecting a repository then you can write tests to your hearts content without worrying about whether the data is real.

Remember what it is you are testing!
You are testing an atomic unit of functionality.  Whether the SSN is real doesn't matter, it's whether the method you are testing handles it correctly.  i.e  will it reject one with too many/too few digits,  will it reject a null entry etc..


问:
Java Design Question
I am considering the options for designing a system in java which accepts data files from different systems applies some transformations to the data, concats data from multiple files to produce some output data files for the downstream systems. The data transformations are not per record transformation, e.g. I need to read a record , then search the file for another record matching the pattern of a given field from the first record

I was thinking of spring batch,but have been asked to consider other options also. Kindly help with any pointers, things to consider while designing and evaluating options.

答:
Well, depending on the complexity vs. load of your application, Spring Batch may or may not be a good solution. This is strictly a personal opinion, but I've found that, while Spring Batch let's you quickly prototype some batching mechanism (you only have to implement the business logic, all the batching mechanism comes out of the box) it can prove slow if you have to deal with very large quantities of data (very complex treatments) and performance is critical.

On the other hand, I've noticed from your question that you say "accepts data files from different systems applies some transformations to the data". If the files come via different channels (such as ftp, web service, etc) then Mule ESB might be a good framework for you. It comes out of the box with connectors for all the various ways of having inter-machines communications (various types of web services, ftp, even email) and gives a simple way to create discrete components for various treatments of those files, which you can chain together any way you like. Besides, the thing is open source so you can easily download it and try it real quick to see if it's a good solution for you.

Other than that, if the overall demand of the project is not very complex in terms of non-business logic needs (like: the sending/receiving of files is only done in one way, and/or the treatment of the files is simple and stable enough to not require any fancy modular system for transform modules, etc), you can go a bit more low level, and just add in a library that handles your communication (like maybe Jersey for web service communications or Apache commons-net for FTP, etc.) and then code everything else by hand. The JDK already comes with quite a few libraries that could be useful, like XML parsers (StAX, JaxB), easy way of handling file I/O (nio2), etc.

Title: Java Design Question


问:
Design guidelines for this scenario in C#?
I have to create a validation system(I don't want to use Data Annotation or any other system) for my C# application using .Net Compact Framework, where I have an object which contains many other objects.

Many of the properties are dependent on each other means they have some sort of dependencies.

I can write a simple validator class which goes through all the properties
and checks them one by one with lots of if and else but I want to design something dynamic e.g. I should be able to specify list of dependencies on a property and specify a method which should be invoked during validation.

I mean some design guidelines would be appreciated ?

Example ( just for demo purpose ):

```<code>    public enum Category
        {
            Toyota,
            Mercedes,
            Tata,
            Maruti
        }

        class MyBigClass
        {
            public Category Category { get; set; }
            public double LowerPrice { get; set; }
            public double UpperPrice { get; set; }

            public SomeOtherObject OtherObject { get; set; }

public List<string> Validate()
        {
            List<string> listErrors = new List<string>();
            ParameterInfo pInfo = null;
            switch (Category)
            {
                case Category.Toyota:
                    pInfo = ParameterStorage.GetParameterInfo(PTYPE.Category_Toyota);
                    break;
                case Category.Mercedes:
                    pInfo = ParameterStorage.GetParameterInfo(PTYPE.Category_Mercedes);
                    break;
                case Category.Tata:
                    pInfo = ParameterStorage.GetParameterInfo(PTYPE.Category_Tata);
                    break;
                case Category.Maruti:
                    pInfo = ParameterStorage.GetParameterInfo(PTYPE.Category_Maruti);
                    break;
                default:
                    break;
            }

            if (LowerPrice < pInfo.Min || LowerPrice >= pInfo.Max)
            {
                listErrors.Add("LowerPrice");
            }

            if (UpperPrice > pInfo.Max || UpperPrice <= pInfo.Min)
            {
                listErrors.Add("UpperPrice");
            }

            return listErrors;
        }
        }

        public enum PTYPE
            {
                RATING,
                Category_Tata,
                Category_Toyota,
                Category_Mercedes,
                Category_Maruti
            }

            public class ParameterInfo
            {
                public PTYPE Type { get; set; }
                public int Min { get; set; }
                public int Max { get; set; }
                public int Default { get; set; }
            }

       public class ParameterStorage
        {
            private static Dictionary<PTYPE, ParameterInfo> _storage = new Dictionary<PTYPE, ParameterInfo>();
            static ParameterStorage()
            {
                _storage.Add(PTYPE.Category_Maruti, new ParameterInfo { Type = PTYPE.Category_Maruti, Min = 50000, Max = 200000 });
                _storage.Add(PTYPE.Category_Mercedes, new ParameterInfo { Type = PTYPE.Category_Mercedes, Min = 50000, Max = 800000 });
                _storage.Add(PTYPE.Category_Toyota, new ParameterInfo { Type = PTYPE.Category_Toyota, Min = 50000, Max = 700000 });
                _storage.Add(PTYPE.Category_Tata, new ParameterInfo { Type = PTYPE.Category_Tata, Min = 50000, Max = 500000 });
            }

            public static ParameterInfo GetParameterInfo(PTYPE type)
            {
                ParameterInfo pInfo = null;
                _storage.TryGetValue(type, out pInfo);
                return pInfo;
            }
        }
</code>```

In the above example I have a MyBigObject which contains some properties and some other objects and I have a storage class which keeps all the limits of properties which will be required to validate a property.

As described in the above example I have to get ParameterInfo for each property and then compare, I am looking for some kind of automatic way/dynamic way of doing the same.

答:
Well, if you want to get rid of those switch statements it's a good idea to use polymorphism to validate objects (e.g. making MyBigClass a class which is supertype for your vehicle brands).

The benefits of this approach are:

You can use dynamic dispatch for methods like validate which are abstract at MyBigClass Level and are implemented in the specific classes (Toyota, Mercedes, ...) which extend MyBigClass

The rules for each vehicle type are encapsulated


答:
You could specify an interface, say IValidatable and use reflection to loop through all the properties and sub properties and validate any which implement the interface. You then only need to implement Validate on each small sub property.

```<code>Many of the properties are dependent on each other means they have some sort of dependencies.
</code>```

This is the root of your problem though. Having something thats hard to validate is just the symptom. Your best best is to split your class into smaller more manageable components.

Title: Design guidelines for this scenario in C#?

Body:
I have to create a validation system(I don't want to use Data Annotation or any other system) for my C# application using .Net Compact Framework, where I have an object which contains many other objects.

Many of the properties are dependent on each other means they have some sort of dependencies.

I can write a simple validator class which goes through all the properties
and checks them one by one with lots of if and else but I want to design something dynamic e.g. I should be able to specify list of dependencies on a property and specify a method which should be invoked during validation.

I mean some design guidelines would be appreciated ?

Example ( just for demo purpose ):

```<code>    public enum Category
        {
            Toyota,
            Mercedes,
            Tata,
            Maruti
        }

        class MyBigClass
        {
            public Category Category { get; set; }
            public double LowerPrice { get; set; }
            public double UpperPrice { get; set; }

            public SomeOtherObject OtherObject { get; set; }

public List<string> Validate()
        {
            List<string> listErrors = new List<string>();
            ParameterInfo pInfo = null;
            switch (Category)
            {
                case Category.Toyota:
                    pInfo = ParameterStorage.GetParameterInfo(PTYPE.Category_Toyota);
                    break;
                case Category.Mercedes:
                    pInfo = ParameterStorage.GetParameterInfo(PTYPE.Category_Mercedes);
                    break;
                case Category.Tata:
                    pInfo = ParameterStorage.GetParameterInfo(PTYPE.Category_Tata);
                    break;
                case Category.Maruti:
                    pInfo = ParameterStorage.GetParameterInfo(PTYPE.Category_Maruti);
                    break;
                default:
                    break;
            }

            if (LowerPrice < pInfo.Min || LowerPrice >= pInfo.Max)
            {
                listErrors.Add("LowerPrice");
            }

            if (UpperPrice > pInfo.Max || UpperPrice <= pInfo.Min)
            {
                listErrors.Add("UpperPrice");
            }

            return listErrors;
        }
        }

        public enum PTYPE
            {
                RATING,
                Category_Tata,
                Category_Toyota,
                Category_Mercedes,
                Category_Maruti
            }

            public class ParameterInfo
            {
                public PTYPE Type { get; set; }
                public int Min { get; set; }
                public int Max { get; set; }
                public int Default { get; set; }
            }

       public class ParameterStorage
        {
            private static Dictionary<PTYPE, ParameterInfo> _storage = new Dictionary<PTYPE, ParameterInfo>();
            static ParameterStorage()
            {
                _storage.Add(PTYPE.Category_Maruti, new ParameterInfo { Type = PTYPE.Category_Maruti, Min = 50000, Max = 200000 });
                _storage.Add(PTYPE.Category_Mercedes, new ParameterInfo { Type = PTYPE.Category_Mercedes, Min = 50000, Max = 800000 });
                _storage.Add(PTYPE.Category_Toyota, new ParameterInfo { Type = PTYPE.Category_Toyota, Min = 50000, Max = 700000 });
                _storage.Add(PTYPE.Category_Tata, new ParameterInfo { Type = PTYPE.Category_Tata, Min = 50000, Max = 500000 });
            }

            public static ParameterInfo GetParameterInfo(PTYPE type)
            {
                ParameterInfo pInfo = null;
                _storage.TryGetValue(type, out pInfo);
                return pInfo;
            }
        }
</code>```

In the above example I have a MyBigObject which contains some properties and some other objects and I have a storage class which keeps all the limits of properties which will be required to validate a property.

As described in the above example I have to get ParameterInfo for each property and then compare, I am looking for some kind of automatic way/dynamic way of doing the same.

Body:
You could specify an interface, say IValidatable and use reflection to loop through all the properties and sub properties and validate any which implement the interface. You then only need to implement Validate on each small sub property.

Many of the properties are dependent on each other means they have some sort of dependencies.

This is the root of your problem though. Having something thats hard to validate is just the symptom. Your best best is to split your class into smaller more manageable components.


答:
Man, if you let a methodology block your project management skills you are misunderstanding the spirit of a methodology... It is there to help, to let you focus on the important and let the repeatable stuff be done without thinking.

Of course you should move those members from the team!


问:
Is Software Testing Really Needed?
I'm a student working on my B.E(CS) and my question is the following:

Is testing in the software field needed?

If we create a software with great care, then why should we test?

After testing can we be sure that we have achieved this goal (the product/software works as intended) because we have done the testing for it? Is it possible?

My question: Is testing of software needed?

答:
I have been a Software tester for 3 years now.
Initially I myself was sceptical about the need to test, since I thought if the development department and project management do their job then no mistakes in software should arise.

BUT   this is not the case.++++++++

Mistakes happen often, some of them critical to the operation of a project.
There is also cross-browser testing( which mean testing on different existing browsers like SAFARI, FIREFOX, CHROME and Internet Explorer) and I worked on the project where simple interface buttons like YES and NO on a survey window where not working in all browsers only some of them.

I worked on internet page testing, and was testing simple TEXT CHANGES and thought to myself that no way on earth there could be defects on this simple work, but no it does happen.

Also I have seen when new developers join the team and are given an update work piece to an existing complex internet application form with a number of linkages/calls to external pages, mistake took place because of lack of the communication between old and new developers, for various reasons ( no time to educate, no will to educate and so on).

Title: Is Software Testing Really Needed?


问:
Multiple orders in a single list
I have a problem with a ranking system I am using.

Scenario:

An online game with around 10k players calculates a real time ranking of points when a certain event occurs. Events don't occur that often, around 1 time per minute. This ranking is kept in the cache for quick calculations, sorting and access.

Now players can form groups and play against each other, but the scoring system is the same, only the ranking is based for the players in that group.

At first I created for every group a separate ranking, effectively having the same scores as the complete ranking, but with different positions in the ranking.

This is trivial because there are over 1.000 groups and every time an event occurs all the groups would have to be updated.

So what I did now is when the group ranking is requested take only the players that are in that group from the complete ranking and show them. The positions would have to be re-counted.

That re-counting is where the problem is. Because the sub-list is by-reference from the complete ranking list I cannot change the position of the player in the sub-ranking without updating it in the complete ranking, because it's just a reference.

I came up with two solutions:

Create a copy from the record every time it is requested and do some output caching (not very desirable because the rankings are live)

Create a copy and store this in a cache which is reset when an event occurs.

Create a sub-list with just the positions which is updated when an event occurs.

And the last solution: do the position counting in the output instead in the business side. This would be the best solution, only problem is that on some pages this text appears: "You are on position # in the ranking" where # is your ranking position. This number would be tedious to get then.

Does anybody have any suggestions to this problem?

答:
As you say yourself, the best solution is to do the counting in the output, instead of storing it in the various lists. That way you don't have to store (and recalculate) the ranking numbers on each event for each (sub-)list, but you only calculate them when needed.

For the "You are on position # in the ranking" text, you could have a method in the class that represents the ranking list, like this: RankingList::getRankingOf(Player). Only if this information is costly to obtain and you only need the ranking from the overall list, you could consider caching the current ranking numbers in the overall list (as an optimisation strategy).

Title: Multiple orders in a single list


问:
The Request/Response Cycle
When User A decides he want to pay a visit to http://example.com/ it all begins with a Request. A short moment later he is given a Response. In this cycle Request-Response a lot is going on, in different frameworks it's decoupled in different components among them Routing, Dispatching, etc.

I'm looking to make a simple experimental MVP Framework for my learning, trying to use as many best practices, heck who knows it might even be worth using when I'm done.

I'm not sure how I should decouple this cycle in to these different components and I'm not even sure of what each component is responsible for (Thinking SOLID, DRY, SRP, etc). That is what I am asking, looking at different frameworks these components seem to have different use-areas from time to time.

What is each of these components responsible for and in what order are the used?

Request, Response, Dispatcher, Router, Front Controller, Bootstrap, Events.

答:
Bootstrap

The bootstrap file is the entry point of your application (index.php). It contains code in the global scope (and this is the only place, where that should be the case). In an outline, it does

create a request object from the request

create a response object according to the requested resource type

ask the router for the responsible controller for the current request

create the controller and call its main method, providing it with the request and respond objects (this often is called dispatching)

echo the response

Request

The request object is used to abstract from the web environment. In the end, it is just a data container (often a copy of $_REQUEST) that allows you make subsequent calls to other controllers (see HMVC).

Response

The response object is managing the output. You may have different response classes for XHTML, HTML5, PDF, JSON, ..., you_name_it with an identical interface. It is responsible for messaging warnings and errors to the user, too.

Router

The router knows, which controller is assigned to which kind of URL. Given the request, it makes a decision about the controller and returns that to the bootstrap.

Dispatcher

A dispatcher is used in different situations. You may think of it like a map and call thingest. For our case, the bootstrap file and the router together make up a dispatcher. A dispatcher is also used to map events to the various event handlers (plugins) and execute them (often using the Observer pattern).

Front Controller

A dispatcher mapping URLs to controllers and executing them dependend on the request is also called a front controller.

Events

the event mechanism is used to decouple systems. You can for example create plugins that take influence on the result of the router. The only thing you have to do for that is to dispatch some events (eg. onBeforeRoute or onAfterRoute) in the routing method. onBeforeRoute would get the request and could change it, before the router even looks at it; onAfterRoute would be able to change the router's output. This is just a small example of whjat you can do with events.

Title: The Request/Response Cycle


问:
How to create different paths for users to take through the pages in my site?
I have a website where users are directed to go through a sequence of pages to perform a sequence of work tasks (transcribe a paragraph, answer a survey, interact with another user, etc). For short, let's call these tasks A, B, C, etc. I'm using Django, and each task is currently implemented as a view function (or method), e.g. def A(request). Currently, each view function has the next step hardcoded in an HTTP redirect, e.g. HttpResponseRedirect(reverse(B)).

My challenge is that I will soon have a requirement to create various permutations of the sequence of tasks. Sometimes I will want users to do A, B, C; for others, B, C, D; for others, A, B, D, F. How can I architect this so that I can define these permutations elegantly and concisely in my code? Intuitively, I feel like I need to genericize the HTTP redirect calls with a variable, like: HttpResponseRedirect(reverse(next_view_function)), but I struggle to figure out where next_view_function should be defined, and how the definition of the sequence (e.g. A, B, D) should be persisted across requests.

Can anyone lead me down the right path with a suggestion or idea? I'm happy to provide more details.

Edit in response to Bart's questions:

The order of tasks is predetermined. Once we have defined it, we send the users a URL that takes them to the first page. They should then be routed through the tasks. One group of users might get a URL that takes them through steps A,B,C, while another group of users gets a URL that takes them through steps A,B,D. We decide in advance which users should get which URL.

Since the order is predetermined, the next step does not depend on the results of the current task. The only requirement is for them to complete the task (we of course validate the POST data they submit as a precondition to the HTTP redirect).

Edit 2, my solution so far:

A central concept in my code architecture is that of a "Treatment" (defined in my models.py). A Treatment is a specification of the experience a user has when they use my site, such as what UI is presented to them. I split my users into groups and assign each group to a different treatment by emailing them a URL that contains the PK of their treatment.

(There are also different subclasses of Treatment, since some Treatments are totally different from others. SoccerTreatment and HockeyTreatment have little in common, so it makes sense to subclass them.)

So, the class definition for a Treatment seems like the sensible place to store the sequence of views as a Python list, as follows:

```<code># in soccer/models.py
class SoccerTreatment(BaseTreatment):

    world_cup = models.BooleanField()
    ....

    def views(self, request):
        seq = [soccer.views.ViewClassA]
        if self.world_cup:
            seq.append(soccer.views.ViewClassWorldCup)

        return seq

# in shared/models.py
class BaseTreatment(models.Model):
    def next_view(self, request):
        seq = self.views() # views() method implemented by descendant classes
        if request.session.get('current_view_index'):
            request.session['current_view_index'] += 1
        else:
            request.session['current_view_index'] = 0
        # [handle boundary cases, code snipped...]
        # ...
        return seq[request.session['current_view_index']]

    # ...

# in views.py, at the end of a view function
# ...
HttpResponseRedirect(reverse(user.treatment.next_view()))
</code>```

However, the design above wouldn't work, since then models.py would have to import views.py, creating a circular import. So the list elements would have to be strings (either URLs, or a the name of the view class as a string), which could be brittle since renaming my classes or URLs won't automatically rename these strings.

Maybe I am being too picky, but I wonder if there is a better design.

答:
You'll have to group your users according to the flow assignments. For each usergroup you have sequence of pages. The data model will then be something like

```<code>User     -->   UserGroup  <--  Sequences
+id            +id             +user_group_id
+name                          +current_step
+user_group_id                 +next_step
</code>```

On each single page you know the user's id and the current step, so you can easily retrieve the next step for the current situation.

Body:
You'll have to group your users according to the flow assignments. For each usergroup you have sequence of pages. The data model will then be something like

User     -->   UserGroup  <--  Sequences
+id            +id             +user_group_id
+name                          +current_step
+user_group_id                 +next_step

On each single page you know the user's id and the current step, so you can easily retrieve the next step for the current situation.


问:
What's the most absurd myth about programming issues?
To put it another way... What is the most commonly held and frustrating misunderstanding about programming, you have encountered?

Which widespread and longstanding myths/misconceptions do you find hard for programmers to dispel/correct.

Please, explain why this is a myth.

答:
That the prototypical programmer:

comes in to work after 11am

drinks nothing but Mountain Dew

loves indian food or sushi

lives alone by choice (with parents and/or in basement)

stays up until 3am playing video games


问:
Disagreement Concerning Data Integration (I may not understand enterprise ETL tools)
I have been in an ongoing conversation concerning a project we are about to undertake at my place at work.  The project concerns data integration.  Our customers want to be able to integrate our data with theirs, either by sending data from their systems into ours, or by getting data from our system into theirs.  I don't believe we are talking about 'big data.'  Our entire database is less than 20 gigs.

The individual transfers from our customers will be very small as well - on the order of 10s of MBs, if not smaller.

A major goal for this project is to minimize the amount of work needed to be done by the customer, who tends to not be very technical.  In the past, this problem has been "solved" by having our customers send us an xml file that is transformed by xlst before being saved to the database, or through a WCF application for exporting data.  These are not seen as good solutions.

My first thought was to create a REST interface with very good monitoring tools and libraries for our clients.

Another option that is being considered are big tools like IBM datastage or Pentaho (or similar).

My personal problem is that when I look at these tools, I don't see how they can help.  It looks like they are aimed at setting up large scale data transfers that happen on a regular schedule with a given format.  Adding a new import/export using those tools requires a lot of setup both for us and the customer, which we are trying to avoid.  They are also not really useful for real-time data updates. Finally, they seem like they are trying to kill an ant with a flamethrower - they are heavyweights for a light weight problem.

In contrast, with a REST setup, data can be transferred whenever required, and Setup only needs to happen in a very small area.

Am I missing something when it comes to these ETL solutions?  Am I not being fair to them?

答:
Nope, you're spot on here. ETL is the wrong choice for this problem, ETL is for information transfers from complex proprietary formats, that are regular and or large and must integrate into other complex proprietary schemas. Also ETL is often the tool of choice for business types as they can be more user friendly for doing data imports/integrations and avoid the overhead of paying for a software engineer, but your company already has SEs on staff which can make a simpler tailor made import that will be more maintainable. It's like access, business types can throw stuff together in it, but the maintainability will be garbage over time and get worse rapidly. Up front cost of throwing an engineer at problems like that is steeper than the business guy + access approach, but in the long run is way cheaper, plus the results are always better for the customers which increases marketability.

You have a simple format available which you can somewhat control, all you need is a REST (or even just FTP and teach them to use some simple FTP client) endpoint for them to upload some block of XML data which you guys already have tools for parsing and importing it sounds like. This is by far a simpler system than ETL will present, and for the problem you are defining, the correct approach.