问:
What is the reason for section 1 of LGPL and what is the implication for section 9.
Why was section 1 added to LGPLv3? My understanding of section 3&4 is, one can convey the combined work under any license and with no requirements from GPLv3 (besides those explicitly stated as requirements in LGPLv3 3&4). Given that, why is section 1 necessary. Wouldn't that sections 3&4 by themselves already imply anyhow what section 1 explicitly states?

I assume that I'm missing something and section 1 isn't redundant. Assuming that, does this have implications for other sections in GPLv3? E.g. does conveying a covered work under sections 3&4 fall under the  patent clause of section 10 of GPLv3? Why does section 1 not also state an exception for section 10?

Put another way. Is the Eigen FAQ correct by stating:

LGPL requires [for header only libraries] pretty much the same as the 2-clause BSD license.

It it true that for  conveying object files including material from LGPLv3 headers no GPLv3 patent clauses apply?

答:
Here's why.  It's due to the opening of the LGPL v3.

This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.

As an answer, that's admittedly a little opaque.  But when we look at Section 1  of the LGPL v3 again, it starts to be a little more clear.

```1. Exception to Section 3 of the GNU GPL.

You may convey a covered work under sections 3 and 4 of this License without being
bound by section 3 of the GNU GPL.```

The opening of the LGPL v3 incorporates all of GPL v3 into itself.  But that creates a problem since Section 3 of the GPL v3: When you convey a covered work, you waive any legal power to forbid circumvention of technological measures ... may run counter to your intent with using the LGPL.

Section 1 of the LGPL v3.0 was put in there to bypass that particular restriction.  LGPL v3 Section 4 discusses reverse engineering for debugging purposes, but GPL v3 Section 3 is much broader in its context.  LGPL v3 Sections 3 & 4 do not create the same restrictions, so they are not equivalent to Section 3 of GPL v3.

Regarding the patent clauses (Sections 10 & 11 of GPL v3): They are in full effect for LGPL v3 and the LGPL V3 Section 1 exception does not apply to them.  Conveying a work through LGPL v3 Sections 3 & 4 has no bearing upon the restrictions created from GPL v3 Sections 10 & 11.

LGPL incorporates the GPL in order to simplify maintaining the licenses.  I can't answer for certain why there isn't an exception clause similar to LGPL v3 Section 1.  However, since the FSF opposes software patents, I can't see them providing an exception to the automatic patent licensing that GPL v3 Section 10 provides.  They want less patents and entanglements, not more.

This answer from SO tipped me off to the major differences between LGPL v2.1 and v3.0

Body:
Here's why.  It's due to the opening of the LGPL v3.

This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.

As an answer, that's admittedly a little opaque.  But when we look at Section 1  of the LGPL v3 again, it starts to be a little more clear.

1. Exception to Section 3 of the GNU GPL.

You may convey a covered work under sections 3 and 4 of this License without being
bound by section 3 of the GNU GPL.

The opening of the LGPL v3 incorporates all of GPL v3 into itself.  But that creates a problem since Section 3 of the GPL v3: When you convey a covered work, you waive any legal power to forbid circumvention of technological measures ... may run counter to your intent with using the LGPL.

Section 1 of the LGPL v3.0 was put in there to bypass that particular restriction.  LGPL v3 Section 4 discusses reverse engineering for debugging purposes, but GPL v3 Section 3 is much broader in its context.  LGPL v3 Sections 3 & 4 do not create the same restrictions, so they are not equivalent to Section 3 of GPL v3.

Regarding the patent clauses (Sections 10 & 11 of GPL v3): They are in full effect for LGPL v3 and the LGPL V3 Section 1 exception does not apply to them.  Conveying a work through LGPL v3 Sections 3 & 4 has no bearing upon the restrictions created from GPL v3 Sections 10 & 11.

LGPL incorporates the GPL in order to simplify maintaining the licenses.  I can't answer for certain why there isn't an exception clause similar to LGPL v3 Section 1.  However, since the FSF opposes software patents, I can't see them providing an exception to the automatic patent licensing that GPL v3 Section 10 provides.  They want less patents and entanglements, not more.

This answer from SO tipped me off to the major differences between LGPL v2.1 and v3.0


问:
"Never do in code what you can get the SQL server to do well for you" - Is this a recipe for a bad design?
It's an idea I've heard repeated in a handful of places. Some more or less acknowledging that once trying to solve a problem purely in SQL exceeds a certain level of complexity you should indeed be handling it in code.

The logic behind the idea is that for the large majority of cases, the database engine will do a better job at finding the most efficient way of completing your task than you could in code. Especially when it comes to things like making the results conditional on operations performed on the data. Arguably with modern engines effectively JIT'ing + caching the compiled version of your query it'd make sense on the surface.

The question is whether or not leveraging your database engine in this way is inherently bad design practice (and why). The lines become blurred further when all the logic exists inside the database and you're just hitting it via an ORM.

答:
As a rule, your DB has more information to work with than your application, and can do common data operations more efficiently. Your database maintains indices, for example, while your application would have to index the search results on the fly. So all else being equal, your overall workload can be decreased by pushing the work to the database rather than the application.

But as your product scales, it typically becomes easier to scale your app than to scale your db. In large installations, is not uncommon to see application servers outnumber database servers by a factor of 10 to 1 or more. Adding more application servers is often a simple matter of cloning an existing server onto new hardware. Adding new database servers, on the other hand, is dramatically more difficult in most cases.

So at this point, the mantra becomes protect the database. It turns out that by caching the database results in memcached or by queueing updates in a application-side log, or by fetching the data once and calculating your statistics in your app, you can dramatically reduce your database workload, saving you from having to resort to an even more complicated and fragile DB cluster configuration.

ContentLicense: CC BY-SA 3.0


问:
How effectively "sell" a good design in large meetings
Many times I have witnessed a sad tragedy.  Here's what happens:

A team design review for a new project.

I see a simple design that has quite a few holes.

I casually mention the holes and ways to avoid them.

The warnings are ignored with comments like "that 'never' happen in real life"

Eventually the things that "will 'never' happen" happen

An emergency team design review for a broken project.

So what do I do?  Copping the "I told you so" attitude is not going to win friends and influence people.  Sometimes years go by and the comments from step 3 are forgotten anyway.  I definitely don't want to be the annoying pest reminding the world of the gotchas.  I often sit back and watch the Titanic sail off to Europe.

It's frustrating to see bad designs move forward.  It's also frustrating that I can't seem to convince others of the pending peril of the current path.  I do worst on team meetings where everyone has different ways of understanding different terms.  Also, egos tend to win of reason and thought.  I'm looking for good tactics to convince groups people to use some new and complicated ideas.

答:
When met with the "that will never happen" scenario, remind them of all the times in the past when they had to fix those "that will never happen" items. But you have to be careful not to come across as "I told you so." I find it most effective to bring up past problems (and how expensive and painful they were to fix) in discussing why you think that we should do something now for this project as examples of why you think this important before they bring of the "that will never happen" quote.

I think perhaps your problem is you say you casually mention a way to avoid a problem, Perhaps you should come armed with more information and show them in more detail why this is a risk to the system. Sometimes that means bring up the subject in a second meeting after you have had time to do a little research. Build a business case for how cheap it is to do now vice how expensive it is to do later.

ContentLicense: CC BY-SA 2.5


问:
Storing Attendance Data in database
So i have to store daily attendance of employees of my organisation from my application . The part where I need some help is, the efficient way to store attendance data. After some research and brain storming I came up with some approaches . Could you point me out which one is the best and any unobvious ill effects of the mentioned approaches. The approaches are as follows

Create a single table for whole organisation and store empid,date,presentstatus as a row for every employee everyday.

Create a single table for whole organisation and store a single row for each day with a comma delimited string of empids which are absent. I will generate the string on my application.

Create different tables for each department and follow the 1 method.

Please share your views and do mention any other good methods

答:
I would create 3 tables: departments, employees, and absences.

```<code>CREATE TABLE departments ( id ... );

CREATE TABLE employees (
  id ...,
  department_id INTEGER REFERENCES departments(id),
  ...
);
</code>```

Each employee would reference a department. If an employee was absent you would create an absence record in the database.

```<code>CREATE TABLE absences (
  ...
  employee_id INTEGER REFERENCES employee(id),
  absence_date DATETIME,
  ...
);
</code>```

So, there would be a row in the absence table for each employee and the day he or she was absent.

You could leave out the departments table if that isn't important.

Title: Storing Attendance Data in database

Body:
I would create 3 tables: departments, employees, and absences.

CREATE TABLE departments ( id ... );

CREATE TABLE employees (
  id ...,
  department_id INTEGER REFERENCES departments(id),
  ...
);

Each employee would reference a department. If an employee was absent you would create an absence record in the database.

CREATE TABLE absences (
  ...
  employee_id INTEGER REFERENCES employee(id),
  absence_date DATETIME,
  ...
);

So, there would be a row in the absence table for each employee and the day he or she was absent.

You could leave out the departments table if that isn't important.


答:
In short, to keep your database table as compact and as efficient as it can be, i would record ONLY days when employee was NOT present.

In addition, you may also have some flag on employee table to indicate that employee is not an active (was retired/fired), and skip logging his presence.

Title: Storing Attendance Data in database

Body:
So i have to store daily attendance of employees of my organisation from my application . The part where I need some help is, the efficient way to store attendance data. After some research and brain storming I came up with some approaches . Could you point me out which one is the best and any unobvious ill effects of the mentioned approaches. The approaches are as follows

Create a single table for whole organisation and store empid,date,presentstatus as a row for every employee everyday.

Create a single table for whole organisation and store a single row for each day with a comma delimited string of empids which are absent. I will generate the string on my application.

Create different tables for each department and follow the 1 method.

Please share your views and do mention any other good methods


问:
How to choose between using a Domain Event, or letting the application layer orchestrate everything
I'm setting my first steps into domain driven design, bought the blue book and all, and I find myself seeing three ways to implement a certain solution. For the record: I'm not using CQRS or Event Sourcing.

Let's say a user request comes into the application service layer. The business logic for that request is (for whatever reason) separated into a method on an entity, and a method on a domain service. How should I go about calling those methods?

The options I have gathered so far are:

Let the application service call both methods

Use method injection/double dispatch to inject the domain service into the entity, letting the entity do it's thing and then let it call the method of the domain service (or the other way around, letting the domain service call the method on the entity)

Raise a domain event in the entity method, a handler of which calls the domain service. (The kind of domain events I'm talking about are: http://www.udidahan.com/2009/06/14/domain-events-salvation/)

I think these are all viable, but I'm unable to choose between them. I've been thinking about this a long time and I've come to a point where I no longer see the semantic differences between the three. Do you know of some guidelines when to use what?

答:
Let the application service call both methods

The application service is usually a great starting place for this, however you should always try to shift behavior as close to the entity as possible. The application service plays an orchestrating role and it sets up the stage for executing domain behavior and as such it provides all required dependencies. However, when possible, it should delegate behavior to the domain model.

Use method injection/double dispatch to inject the domain service into
  the entity, letting the entity do it's thing and then let it call the
  method of the domain service (or the other way around, letting the
  domain service call the method on the entity)

This is a better approach because more of the behavior is delegated to the entity or domain service. The most decoupled way to implement this is to have an entity express a dependency on a service is as a parameter of the method providing the behavior at hand.

Raise a domain event in the entity method, a handler of which calls
  the domain service.

The domain event pattern, as explain by Udi and also Evans himself, is quite versatile and can be applied in a variety of scenarios. There are a few complications that come with it however. First, you have to make sure that you have proper scoping within the domain event publisher. Most of the time, your domain event handlers will have dependencies and if you are using an IoC container, you have to make sure that a proper instances are injected. For example, in a web application, the [ThreadStatic] attribute is problematic for scoping. Another complexity is that of transcriptional boundaries. You have to take transactions into consideration, because if an entity raises a domain event, but a subsequent commit to the database fails, all domain event handlers will need a way to roll back, otherwise you will end up raising an invalid event. If however you've got these bases covered, then domain events are a great pattern for encapsulating domain logic within the entities themselves.

The difference between approach 2 and 3 depends on the use case. A domain event applies when you want to invoke additional behaviors in response to an event, which is in the past tense. This is an important constraint, since the domain event handler can't affect behavior of the entity. On the other hand, with approach 2, the injected service has the potential to affect behavior because it is declared a dependency for that particular behavior.


问:
handling a GET error properly
I have a website that takes two primary get strings:

```<code>?type=GAME&id=SomeGameID
?type=SCENARIO&id=SomeScenarioID
</code>```

for reasons unknown, I have recently begun receiving requests for erroneous get strings from both Yandex and Baidu. They are always in the form of:

```<code>?type=GAME&id=SomeScenarioID
</code>```

None of my users are triggering these errors, so I am (sort of) confident that this is not due to an HTML template error somewhere on my part. There is also no HTTP_REFER showing up in the $_SERVER array, so I'm guessing these are direct requests from bad dbase data on their part.

I see two options for dealing with these bad requests, and would like to know which is recommended... or if there are other, better options I have not thought of:

simply 404 the request, since it is incorrect

redirect the request to ?type=SCENARIO&id=SomeScenarioID because the scenario IDs are always valid, the breakage is due to asking for the wrong type.

答:
I would favor 404 over 400 in this situation.  400 means the request is malformed, but the request you described is not malformed.  The request is for a GAME that does not exist; this is the definition of error 404.

If there were a way to know: the request is for a GAME, but the ID given is clearly a scenario ID, then this would constitute malformed syntax.  However, based on your statements in the comments, there is no discernible difference between game IDs and scenario IDs.  The game ID being requested is a valid ID, it simply doesn't exist.

This is the same reason your redirect idea would not be good.  You can't know that someone is actually looking for a SCENARIO if they have specifically asked for a GAME.  If a consumer asked for a GAME but accidentally passed a bad ID and got redirected to a SCENARIO, they would be terribly confused.

Title: handling a GET error properly


问:
Is it OK to push my code to GitHub while it is still in early development?
I have some projects that are in a very early development state. They are nowhere nearing completion but I do host them (as public repos) on GitHub because:

I have multiple computers and I want access to my code everywhere

I want a backup for my code

I want it to be easy if someone wants to collaborate in some way

I use GitHub Issues as a poor man's project management software

Is it OK to publish a project on GitHub even when it is very early in the development? I am a bit concerned about someone to come by and say OMG this is total BS, this code is so bad! while looking at unpolished/still in development/not tested code.

What are your practices when you start new public projects? Do you wait until you have something substantial to show or you create a bare repo directly on GitHub and start from there?

I used GitHub throughout this post but this applies to every code hosting service out there.

答:
Push whatever you want as early as possible.  No one's going to look at it unless you publicise it and it's interesting.

If you're really worried, some free code hosting services offer private repositories.


答:
Of course it is OK: it is hard to imagine that over 4,098,118 projects currently hosted on GitHub would all be 100% great and useful! You are not forcing anyone to use your code or even to look at it. If you host the project primarily for yourself, the quality of your code is of concern to you, and nobody else.

You listed all the right reasons to host your project - backups, universal access, and possibility of collaboration with others are great reasons to start hosting as early as possible.

Title: Is it OK to push my code to GitHub while it is still in early development?

Body:
I have some projects that are in a very early development state. They are nowhere nearing completion but I do host them (as public repos) on GitHub because:

I have multiple computers and I want access to my code everywhere

I want a backup for my code

I want it to be easy if someone wants to collaborate in some way

I use GitHub Issues as a poor man's project management software

Is it OK to publish a project on GitHub even when it is very early in the development? I am a bit concerned about someone to come by and say OMG this is total BS, this code is so bad! while looking at unpolished/still in development/not tested code.

What are your practices when you start new public projects? Do you wait until you have something substantial to show or you create a bare repo directly on GitHub and start from there?

I used GitHub throughout this post but this applies to every code hosting service out there.


答: Sure you can publish it in an early development - But mark it as pre-alpha, later set alpha, beta...</p>


问:
Is executing SQL through a WebService a really bad idea?
Typically when creating a simple tool or something that has to use a database, I go through the fairly long process of first creating a webservice that connects to a database then creating methods on this webservice that do all the type of queries I need.. methods like

```<code>List<Users> GetUsers()
{
    ...
}
User GetUserByID(int id)
{
    ...
}
//More Get/Update/Add/Delete methods
</code>```

Is it terrible design to simply make the webservice as secure as I can (not quite sure the way to do something like this yet) and just make a couple methods like this

```<code>SqlDataReader RunQuery(string sql)
{
     ...
}

void RunNonQuery(string sql)
{
     ...
}
</code>```

I would sorta be like exposing my database to the internet I suppose, which sounds bad but I'm not sure.

I just feel like I waste so much time running everything through this webservice, there has to be a quicker yet safe way that doesn't involve my application connecting directly to the database (the application can't connect directly to database because the database isn't open to any connections but localhost, and where the appliction resides the standard sql ports are blocked anyway)

Especially when I just need to run a few simple queries

答:
I'll play Devil's advocate here, and say 'maybe not'. The major issue is security, which I'll come to later.

Hands up if you are a fan of the relational model. For many domains, it's the only one that makes sense. SQL is the only serious language we have for asking arbitrary (not predefined) questions about a given dataset.

With a traditional HTTP based web service, you are restricted to asking the questions the API designer thought of (and could be bothered to implement). Of course, you can grab as much data as you can and do the 'joins' on your side, missing out on the benefits of the relational model. This route is fraught with bugs, duplicated effort, brittleness, and the rest.

If you want consumers of your data API to be able to ask questions that you don't know in advance, SQL is the best language.

Of course security is why your question sets off so many red flags, and there aren't established best practices to follow, because almost no one allows SQL-level access in the first place.

Some databases allow you to restrict users to a set of particular views, and can prevent destructive (INSERT, DELETE, etc.) operations, preventing many of the injection issues raised by other answers. Allowing only view based access would also allow a degree of decoupling from the actual table structure.

Finally, Tom Squires rightly points out that HTTP isn't adding much value here. You may as well just allow direct DB connections.


答:
After seeing the OP comment about what he is going to do with these data, I thought this could be added to axblount's answer.

Have a dates lookup table:  http://www.techrepublic.com/blog/datacenter/simplify-sql-server-2005-queries-with-a-dates-table/326

One query that will be difficult is to calculate the working days that occured in a given time span.

Use a Holiday table. The dates lookup table can be queried to find dates not in the Holiday table to find out how many days someone was expected to work. Paid holdays can be calculated as well.

Title: Storing Attendance Data in database


问:
Being productive during downtime
Lets say you are somewhere where coding and getting online isn't possible (On a busy flight, for example)what do you do to stay productive?

Things I would do are read whatever tech book I am currently slogging through and maybe doodle some UI stuff or workflows.  What else could I be doing?

答:
Why not use that slack to relax and free your mind?

If you are 100% of your time busy, thinking, working, inventing, etc, THAT will makes you less productive.

EDIT: Even in World Of Warcraft you have to rest ;) (no I don't play wow, but I feel it's a good example)

Title: Being productive during downtime


问:
algorithm to print the digits in the correct order
I've been trying to write an algorithm that will print separately the digits from an integer. I have to write it in Pseudocode. I know how to write an algorithm that reverse the digits.

```<code>digi(n):
  while n != 0:
    x = n % 10
    n = n // 10
    print (x)
</code>```

But I don't know how to write an algorithm to print the digits in the correct order. For example, the input is integer 123467 and the output is: 1 2 3 4 6 7. The numbers will be input from the user, and we cannot convert them to a string. I need help getting started on writing algorithms.

答:
log n will give you the number of (decimal) digits in n.

Notice that 1234 / (10^[4-1]) = 1.234 which rounds down to 1. Repeat as necessary (mod 10) to print each digit.

1.234 -> 1

12.34 % 10 -> 2.34 -> 2

123.4 % 10 -> 3.4  -> 3

1234 % 10          -> 4


答: If you already have an algorithm to print them in reverse put them in a stack and then print the stack which will reverse the order.</p>

Body:
I've been trying to write an algorithm that will print separately the digits from an integer. I have to write it in Pseudocode. I know how to write an algorithm that reverse the digits.

```<code>digi(n):
  while n != 0:
    x = n % 10
    n = n // 10
    print (x)
</code>```

But I don't know how to write an algorithm to print the digits in the correct order. For example, the input is integer 123467 and the output is: 1 2 3 4 6 7. The numbers will be input from the user, and we cannot convert them to a string. I need help getting started on writing algorithms.


问:
Increase application performance
I'm writing a program for a company that will generate a daily report for them.  All of the data that they use for this report is stored in a local SQLite database.  For this report, the utilize pretty much every bit of the information in the database.  So currently, when I query the datbase, I retrieve everything, and store the information in lists.  Here's what I've got:

```<code>using (var dataReader = _connection.Select(query))
{
    if (dataReader.HasRows)
    {
        while (dataReader.Read())
        {
            _date.Add(Convert.ToDateTime(dataReader["date"]));
            _measured.Add(Convert.ToDouble(dataReader["measured_dist"]));
            _bit.Add(Convert.ToDouble(dataReader["bit_loc"]));
            _psi.Add(Convert.ToDouble(dataReader["pump_press"]));
            _time.Add(Convert.ToDateTime(dataReader["timestamp"]));
            _fob.Add(Convert.ToDouble(dataReader["force_on_bit"]));
            _torque.Add(Convert.ToDouble(dataReader["torque"]));
            _rpm.Add(Convert.ToDouble(dataReader["rpm"]));
            _pumpOneSpm.Add(Convert.ToDouble(dataReader["pump_1_strokes_pm"]));
            _pumpTwoSpm.Add(Convert.ToDouble(dataReader["pump_2_strokes_pm"]));
            _pullForce.Add(Convert.ToDouble(dataReader["pull_force"]));
            _gpm.Add(Convert.ToDouble(dataReader["flow"]));
        }
    }
}
</code>```

I then utilize these lists for the calculations.    Obviously, the more information that is in this database, the longer the initial query will take.  I'm curious if there is a way to increase the performance of the query at all?  Thanks for any and all help.

EDIT

One of the report rows is called Daily Drilling Hours.  For this calculation, I use this method:

```<code>// Retrieves the timestamps where measured depth == bit depth and PSI >= 50
public double CalculateDailyProjectDrillingHours(DateTime date)
{
    var dailyTimeStamps = _time.Where((t, i) => _date[i].Equals(date) &&
                                        _measured[i].Equals(_bit[i]) &&
                                        _psi[i] >= 50).ToList();
        return
            _dailyDrillingHours =
            Convert.ToDouble(Math.Round(TimeCalculations(dailyTimeStamps).TotalHours, 2, MidpointRounding.AwayFromZero));
}

// Checks that the interval is less than 10, then adds the interval to the total time
private static TimeSpan TimeCalculations(IList<DateTime> timeStamps)
{
    var interval = new TimeSpan(0, 0, 10);
    var totalTime = new TimeSpan();
    TimeSpan timeDifference;

    for (var j = 0; j < timeStamps.Count - 1; j++)
    {
        if (timeStamps[j + 1].Subtract(timeStamps[j]) <= interval)
        {
            timeDifference = timeStamps[j + 1].Subtract(timeStamps[j]);
            totalTime = totalTime.Add(timeDifference);
        }
    }

    return totalTime;
}
</code>```

答:
If I understand what you're doing correctly, then you're actually copying the whole database into memory and querying it using Linq. This is extremely wasteful since you now have the data both in memory and in the database itself. What you need to do it to query the database itself for the data you need, which is what a database was designed for. For that you'll need to learn SQL. For instance, look at this Linq query:

```<code>var dailyTimeStamps = _time.Where((t, i) => _date[i].Equals(date) &&
                                        _measured[i].Equals(_bit[i]) &&
                                        _psi[i] >= 50).ToList();
</code>```

You're pulling a list of all timestamps just to filter it to a few. However, using a SQL query like this:

```<code>SELECT timestamp
FROM table
WHERE date = @date
AND measured_dist = bit_loc
AND pump_press >= 50
</code>```

This will immidiately give you a list of the timestamps you need, without having to load the whole data in memory.

Title: Increase application performance

Body:
If I understand what you're doing correctly, then you're actually copying the whole database into memory and querying it using Linq. This is extremely wasteful since you now have the data both in memory and in the database itself. What you need to do it to query the database itself for the data you need, which is what a database was designed for. For that you'll need to learn SQL. For instance, look at this Linq query:

var dailyTimeStamps = _time.Where((t, i) => _date[i].Equals(date) &&
                                        _measured[i].Equals(_bit[i]) &&
                                        _psi[i] >= 50).ToList();

You're pulling a list of all timestamps just to filter it to a few. However, using a SQL query like this:

SELECT timestamp
FROM table
WHERE date = @date
AND measured_dist = bit_loc
AND pump_press >= 50

This will immidiately give you a list of the timestamps you need, without having to load the whole data in memory.


问:
MVC Can the model know ANYTHING about the view?
I'm working on a game, and without getting into any details I am using MVC "patterns", "rules" or whatever you want to call it to make the game.

The view includes everything needed to draw things on the screen, the controller passes input to the model. And the Model contains game logic.

Here's my problem, the game is being made for mobile devices that vary in screen sizes. I feel my model needs to know the view size so it can appropriately adjust for it.

I've thought about it for a while I could put all the adjustments in the view, but it just seems inefficient to translate the model positioning to the view's needed positioning every time. If the model knows the size it only needed to adjust itself once.

So my question is can I pass the view size to the model without 'breaking' MVC? I feel personally they are still decoupled this way because a size is just a number, I could still change the view any time as long as it has a size. But I wanted to get a community response on this because I haven't seen many discussions of MVC being used in a game.

(And to be clear I don't want an answer of why I shouldn't use it in a game, but do I break MVC by letting it know the view's size)

EDIT - More details on the game's needs and why I wanted to pass the view.

Some objects positions need to be set relative to the edge of the screen (such as UI elements) so that they appear relatively in the same place. Sprite sizes are not stretched if the window size is wider such as an IPhone 5 screen. They will just be placed relatively to the screen edge. .If I gave it to the view to handle this, I will need a flag saying that this element is positioned say x number of pixels from TOP BOTTOM RIGHT LEFT. Then allow the view to draw it with that information. Its acceptable, I just wanted to know if there was a better way while still being MVC because it seems this way will be repeating a logic over and over, where as if I knew the view size in the model, I could convert all the relative positions into absolute positions in one run, but with this I have to convert on every update to the screen.

答: If the model doesn't need to know the size of the view (say for edge detection or collisions), then I don't think it needs to have that information.  Can your model express locations/distances in some neutral format ("layout units" or something) that will make it easy to scale for the various screen sizes?  Or does the screen size affect gameplay (there may be more enemies/targets to track on a larger screen)?  If so, then it makes sense to define the playfield size in the model.</p>


答:
Don't put any presentation support in the model.  For example, a model for a chess game would keep track of the piece positions and the player on move, report whether the game is over, and produce a list of all legal moves.  All the presentation logic, such as calculating the screen position for a square on the chessboard, and rendering a chessman, should be done in the view.

If you are implementing multiple views, then factor out common code into a view service module or a view base class.

Title: MVC Can the model know ANYTHING about the view?

Body:
I'm working on a game, and without getting into any details I am using MVC "patterns", "rules" or whatever you want to call it to make the game.

The view includes everything needed to draw things on the screen, the controller passes input to the model. And the Model contains game logic.

Here's my problem, the game is being made for mobile devices that vary in screen sizes. I feel my model needs to know the view size so it can appropriately adjust for it.

I've thought about it for a while I could put all the adjustments in the view, but it just seems inefficient to translate the model positioning to the view's needed positioning every time. If the model knows the size it only needed to adjust itself once.

So my question is can I pass the view size to the model without 'breaking' MVC? I feel personally they are still decoupled this way because a size is just a number, I could still change the view any time as long as it has a size. But I wanted to get a community response on this because I haven't seen many discussions of MVC being used in a game.

(And to be clear I don't want an answer of why I shouldn't use it in a game, but do I break MVC by letting it know the view's size)

EDIT - More details on the game's needs and why I wanted to pass the view.

Some objects positions need to be set relative to the edge of the screen (such as UI elements) so that they appear relatively in the same place. Sprite sizes are not stretched if the window size is wider such as an IPhone 5 screen. They will just be placed relatively to the screen edge. .If I gave it to the view to handle this, I will need a flag saying that this element is positioned say x number of pixels from TOP BOTTOM RIGHT LEFT. Then allow the view to draw it with that information. Its acceptable, I just wanted to know if there was a better way while still being MVC because it seems this way will be repeating a logic over and over, where as if I knew the view size in the model, I could convert all the relative positions into absolute positions in one run, but with this I have to convert on every update to the screen.


问:
Object oriented wrapper around a dll
So, I'm writing a C# managed wrapper around a native dll. The dll contains several hundred functions. In most cases, the first argument to each function is an opaque handle to a type internal to the dll.

So, an obvious starting point for defining some classes in the wrapper would be to define classes corresponding to each of these opaque types, with each instance holding and managing
the opaque handle (passed to its constructor)

Things are a little awkward when dealing with callbacks from the dll. Naturally, the callback handlers in my wrapper have to be static, but the callbacks arguments invariable contain an opaque handle.

In order to get from the static callback back to an object instance, I've created a static dictionary in each class, associating handles with class instances. In the constructor of each class, an entry is put into the dictionary, and this entry is then removed in the Destructors. When I receive a callback, I can then consult the dictionary to retrieve the class instance corresponding to the opaque reference.

Are there any obvious flaws to this? Something that seems to be a problem is that the existence static dictionary means that the garbage collector will not act on my class instances that are otherwise unreachable. As they are never garbage collected, they never get removed from the dictionary, so the dictionary grows. It seems I might have to manually dispose of my objects, which is something absolutely would like to avoid.

Can anyone suggest a good design that allows me to avoid having to do this?

答: Can't you simply make the static dictionary use weak references?</p>

Title: Object oriented wrapper around a dll


答:
If I'm not relaxing then I personally:

Write some more of my technical book ("Hi Editor!")

Read tech books/articles etc that I save up for such journeys

Read stuff that's completely outside of my field (broaden that mind)

Update my personal Kanban board

Write up a bunch of lightning talks, presentations & blog posts that I want to give in the future

Talk to my wife about user experience design

Title: Being productive during downtime

Body:
Lets say you are somewhere where coding and getting online isn't possible (On a busy flight, for example)what do you do to stay productive?

Things I would do are read whatever tech book I am currently slogging through and maybe doodle some UI stuff or workflows.  What else could I be doing?


问:
Can data classes contain methods for validation?
OK, say I have a data class for a user:

```<code>public class User {
private String firstName;
private String lastName;
private long personCode;
private Date birthDate;
private Gender gender;
private String email;
private String password;
</code>```

Now let's say I want to validate email, whether names are not empty, whether birth date is in normal range, etc. Can I put that validation method in this class together with data? Or should it be in UserManager which in my case handles the lists of these users?

答:
You can definitely validate these attributes in your setters(). Unlike getters which are meant to return values, setters are methods to assign a value via an argument/parameter.

Ideally, i would advise you to write separate methods and have their return values true or false. for validating your class attributes particularly when the validation is quite extensive.

Examples:

bool validateEmail(string email) {

}

bool validatePassword(string pwd) {

}

bool validateBirthdate(date dob) {

}

I would rather advise to validate your class attributes in the Business Logic Layer. I wonder if you know about the software logical architecture. FYI: BLL

Also if you have a database then it is best to have them validated there via constraints.


答:
Sure you can push whatever you want, but still it is better when you push a more pre beta solution to GitHub.

You can easily use DropBox for storing you GitHub projects and the good part is that you'll have access to them on any computer.


答:
If you are coding in Java, you should take a look at Bean Validation, that is part of the Java EE 6 specification. It uses metadata (annotations) to help validation handling. Bean validation can also be used in other layers.

Hope it helps you.

Title: Can data classes contain methods for validation?

Body:
OK, say I have a data class for a user:

```<code>public class User {
private String firstName;
private String lastName;
private long personCode;
private Date birthDate;
private Gender gender;
private String email;
private String password;
</code>```

Now let's say I want to validate email, whether names are not empty, whether birth date is in normal range, etc. Can I put that validation method in this class together with data? Or should it be in UserManager which in my case handles the lists of these users?


答:
In short, YES you can definitely implement that validation method on a class.

I would also advice to define validation method (or methods) through a common interface like IValidate. It will look somewhat like:

```<code>public class User: IValidate
{}
</code>```

You may define the generic public bool IsValid() method signature and others that make sense in the given context.

Body:
In short, YES you can definitely implement that validation method on a class.

I would also advice to define validation method (or methods) through a common interface like IValidate. It will look somewhat like:

public class User: IValidate
{}

You may define the generic public bool IsValid() method signature and others that make sense in the given context.


问:
Which would be the best platform to develop websites to be used with very slow connections without sacrificing too much the design?
How can we give dial-up users in some remote places or less developed countries, a good experience while using dynamic websites.</p>

答:
Use YSlow to understand how you can optimize your website and follow all webpage optimization best practices.

YSlow analyzes web pages and why they're slow based on Yahoo!'s rules for high performance web sites.

Visit YSlow official website for more info: http://yslow.org


问:
Why didn't "cloud computing" offer appear earlier?
Cloud computing is a model of renting resources - servers and data storage. Both servers and data storage have been around for much more than a decade so far. Yet cloud computing offers only appeared several years ago.

What's the deal here? What was the critical change that triggered massive adoption and massive marketing of cloud computing offers?

答:
In addition to Chloe's excellent answer, I would say that the following factors have caused cloud computing to explode in popularity:

Growth of Internet use, and hence, Internet-related services (am including mobile services here, which mostly use Internet functionality)

Need for cheap, homogenous, easy-to-setup hardware for companies, startups, etc.

API-based (programming) control to set up new servers and scale them up or down

I personally think #3 is most important: if you are managing 100s or 1000s of servers, would you rather do through a command line or a GUI ... or drive miles to get to your co-location services?

Of course, even if these had happened, it could have not been possible to do without the level of virtualization technology we have today, which directly helps point #3.

In short, I would say it was a perfect storm of factors that have enabled cloud computing to exist today in its current form, and to grow rapidly in popularity.


答:
There's a Chinese proverb:

Resting is for the purpose of traveling a further distance...

Title: Being productive during downtime


答:
As mentioned before, the goal is to send to and receive as little as possible from the database because the round trips are very costly time-wise. Sending SQL statments over and over again is a waste of time especially in more complex queries.

Using stored procedures in the database allows developers to interact with the database like an API, without worrying about the complex schema on the back. It also reduce the data sent to the server since only the name and a few parameters are sent. In this scenario, most of the bussines logic can still be in the code but not in the form of SQL. The code would essentially prepare what is to be sent or requested from the database.

Title: "Never do in code what you can get the SQL server to do well for you" - Is this a recipe for a bad design?

Body:
It's an idea I've heard repeated in a handful of places. Some more or less acknowledging that once trying to solve a problem purely in SQL exceeds a certain level of complexity you should indeed be handling it in code.

The logic behind the idea is that for the large majority of cases, the database engine will do a better job at finding the most efficient way of completing your task than you could in code. Especially when it comes to things like making the results conditional on operations performed on the data. Arguably with modern engines effectively JIT'ing + caching the compiled version of your query it'd make sense on the surface.

The question is whether or not leveraging your database engine in this way is inherently bad design practice (and why). The lines become blurred further when all the logic exists inside the database and you're just hitting it via an ORM.


答: The defining characteristics of cloud computing are scalability and utility billing. Client/servers, thin clients, and ASPs mentioned by Jörg W Mittag are not cloud computing, unless they automatically scale up and down in real time with the customer being billed for the amount of resources (CPU, disk space, bandwidth) that they use. As Chloe correctly noted, this model only became possible with the advances in virtualization technology and high-speed Internet connections. These have been taking place within the last 5–10 years, hence this is when we started to hear about cloud computing.</p>

Title: Why didn't "cloud computing" offer appear earlier?

Body:
Cloud computing is a model of renting resources - servers and data storage. Both servers and data storage have been around for much more than a decade so far. Yet cloud computing offers only appeared several years ago.

What's the deal here? What was the critical change that triggered massive adoption and massive marketing of cloud computing offers?


答:
The idiom is more to do with keeping the business rules, to do with the data, together with the relations (the data and structure and relationships.) It's not a one-stop-shop for every problem but it helps to avoid things like manually maintained record counters, manually maintained relationship integrity etc, if these things are available at the database level. So if someone else comes along and extends the programs or writes another program that interacts with the database, they won't have to figure out how to maintain database integrity from previous code. The case of a manually maintained record counter is particularly pertinent when someone else wants to author a new program to interact with the same database. Even if the newly created program has exactly the right code for the counter, the original program and the new one running at approximately the same time are likely to corrupt it. There's even code out there that retrieves records and checks conditions before writing a new or updated record (in code or as separate queries), when if possible this can often be achieved right in the insert or update statement. Data corruption can again result. The database engine guarantees atomicity; an update or insert query with conditions is guaranteed to affect only the records meeting the conditions and no external query can change the data half way through our update. There's many other circumstances where code is used when the database engine would better serve. It's all about data integrity and not about performance.

So it's actually a good design idiom or rule of thumb. No amount of performance is going to help in a system with corrupt data.


答: What optimizers won't do for you is minimize the use of large multimedia (graphic mostly) files. Unnecessarily oversided graphics and lots of them typically accounts for most of the waiting times on dial-up. A minimalist approach to both the number of separate downloads and their size, would be good.</p>

Title: Which would be the best platform to develop websites to be used with very slow connections without sacrificing too much the design?

Body: How can we give dial-up users in some remote places or less developed countries, a good experience while using dynamic websites.</p>


答: You could use Bitbucket which has most of the project management features, all of the cloud-based DCVS features and it has free private repositories so you can keep it on the DL.</p>


答: No one is just going to stumble on your project. And if they did they aren't going to go blabbing all over the internet about it.</p>


问:
What did programmers do before variable scope, where everything is global?
So, I am having to deal with seemingly archiac language (called PowerOn) where I have a main method, a few datatypes to define variables with, and has the ability to have sub-procedures (essentially void methods) that does not return a type nor accepts any arguements.  The problem here is that EVERYTHING is global.  I've read of these type of languages, but most books take the aproach "Ok, we use to use a horse and cariage, but now, here's a car so let's learn how to work on THAT!" We will NEVER relive those days".  I have to admit, the mind is struggling to think outside of scope and extent.

Well here I am.  I am trying to figure out how to best manage nothing but global variables across several open methods.  Yep, even iterators for for loops have to be defined globaly, which I find myself recycling in different parts of my code.

My Question:  for those that have this type experience, how did programmers deal with a large amount of variables in a global playing field?  I have feeling it just became a mental juggling trick, but I would be interested to know if there were any known aproaches.

答:
I actually learned to program in a language called Authorware, where everything was global. Luckily, it did have Arrays and after a certain point something called Lists, which were similar to generic objects.

An Authorware program actually had a physical structure (Authorware was based on a flow-chart metaphor), and its scripting language was based on old-style Pascal. What we did was to relate the physical structure to the indices in an Array, and often the Array indices would contain Lists that we'd treat as a local object for the physical piece we were using.

Authorware was designed for eLearning, so one of the icons we had was a Page. Pages would be attached to a Framework. So, for Page 1, we'd look in some Array at index 1 (Authorware was 1-indexed) and pull out the data for that page, which would be stored a List that would act as a pseudo-object.  The Page would then have logic that would pull out the "properties" of the object by name. If you don't have anything like Objects, but you have Arrays, you can simply have a convention of what data goes where.

It's not really that different from what we do when we retrieve data from a database and perform dependency injection, except that everything's really global, and you're simply choosing to put everything into little boxes and only look at the one(s) you're concerned with right now.

Depending on what you're trying to do and what your language supports, this might help you at least break things down into more manageable chunks.


问:
Using Completed User Stories to Estimate Future User Stories
In Scrum/Agile, the complexity of a user story can be estimated in story points.  After completing some user stories, a programmer or team of programmers can use those experiences to better estimate how much time it might take to complete a future user story.

Is there a methodology for breaking down the complexity of user stories into quantifiable or quantifiable attributes?

For example, User Story X requires a rich, new view in the GUI, but User Story X can perform most of its functionality using existing business logic on the server.  On a scale of 1 to 10, User Story X has a complexity of 7 on the client and a complexity of 2 on the server.  After User Story X is completed, someone asks how long would it take to complete User Story Y, which has a complexity of 3 on the client and 6 on the server.  Looking at how long it took to complete User Story X, we can make an educated estimate on how long it might take to complete User Story Y.

I can imagine some other details:

The complexity of one attribute (such as complexity of client) could have sub-attributes, such as number of steps in a sequence, function points, etc.

Several other attributes that could be considered as well, such as the programmer's familiarity with the system or the number of components/interfaces involved

These attributes could be accumulated into some sort of user story checklist.

To reiterate:  is there an existing methodology for decomposing the complexity of a user story into complexity of attributes/sub-attributes, or is using completed user stories as indicators in estimating future user stories more of an informal process?

答: In my experience it is very informal. If the team is fairly experienced they should be able to look at a story and decide if it's going to require about the same effort as another story, or considerably more, or considerably less. Story points are only approximate, so accuracy isn't much of a concern as long as you apply your judgement somewhat consistently.</p>


问:
Is SOA an Utopia?
I have attended to many SOA related sales pitches and presentations through the years. SOA projects have died because of lack of interest or because of grandiose scopes. The very buzzword has lost momentum.

Has someone seen SOA implemented ? Or is it a kind of utopian vision one must strive for ? Do one have to believe in SOA without touching it or having seen it ?

答:
My take is that yes, it's a complete buzzword for the following reasons:

1) Too many people equate SOA with only web services.

2) Re-packaged message brokers and other obsolete technologies (visual programming) as "ESBs".  Ironically this leads to vendor lock-in and less flexibility because you don't have the source code.

3) No focus on where solutions are appropriate -- maybe FTP is an appropriate method of transfer for data which isn't necessary right away but needs archived, maybe HTTP is too prone to failure (or blocking) and a message-based architecture is more appropriate -- just EVERYTHING IS A WEB SERVICE!

4) Too much focus on re-usability and flexibility makes an architecture sloppy and limp, and takes away from simply solving the problem (or solving the problem simply).

Title: Is SOA an Utopia?


答:
Rely heavily on caching at the browser level (meta-tags -- use Firebug or equivalent to evaluate your calls to the server and verify resources are being cached on the client side).

For dynamic content, use AJAX w/ JSON (not XML) to minimize browser traffic and post-backs. (Or experiment with websockets if you can guarantee which browser they are using).

Experiment with coding more logic within the JavaScript itself (JS MVC?) -- again to eliminate calls to the server.

High compression on any images

Minify any JavaScript used

You're goal is going to be to pass as little to and from the browser as possible in the least amount of call-backs to the server. See Yahoo's Guide as well.


答:
Do one have to believe in SOA without touching it or having seen it ?

I think your question is really good one. I personally think that SOA and buzz around it has provided a good momentum for development of related Web API technologies. Just look at  O-Data, ASP.NET MVC API  and  WCF. They are all have some bits and bites of SOA.

As was mentioned, there is a big mis-understanding on what is SOA really is:

As mentioned, SOA have more global meaning than just a web-service. And now: the REST having a big BUZZ wave as well...

Title: Is SOA an Utopia?

Body:
I have attended to many SOA related sales pitches and presentations through the years. SOA projects have died because of lack of interest or because of grandiose scopes. The very buzzword has lost momentum.

Has someone seen SOA implemented ? Or is it a kind of utopian vision one must strive for ? Do one have to believe in SOA without touching it or having seen it ?


答:
I think Watson needs to qualify his point #5: Minimize JavaScript.  I think what he means with is point #3 is if you have a page that needs to build a lot of HTML around a list of very small bits of data, you can build the data into an array in JavaScript and have it build that part of the page using Document.write().  For instance, on a page that has to list many long strings separated by commas or by semicolons, you could just list the strings once.

```<code>var emailAddrs = new Array("address1@nowhere.com",
    "address2@nowhere.com",
    ...
    "addressN@nowhere.com");
function showEmailAddrs(semicolon) {
    var innerHtml = '<a href="mailto:javascript:hideEmailAddrs();">Hide email addresses<\/a><br \/>\n<span class="normal">';
    if (semicolon) {
        innerHtml += emailAddrs.join('; ');
    } else {
        innerHtml += emailAddrs.join(', ');
    }
    innerHtml += '<\/span>';
    document.getElementById("emailAddrs").innerHTML = innerHtml;
}
</code>```

With a long list, you can see how this would save almost half the size.  If the JavaScript built <option value="123"> tags around a few thousand strings, you can save even more space.  As others have said, avoid large images.  I would also have to add:

Theories only get you so far.  Believe what you time, and time everything.  I like to make each timing test 10 times, arrange the results in ascending order and average the middle two times.  Record your time before you start optimizing so you are sure that you are making things better and not worse.  I time the server, I time the client...  you get the picture.

Use the built-in timers in the "Developer Tools" in most browsers.

Don't use HTTPS unless you have to - it turns off browser caching.

Time the difference between using separate CSS and JavaScript files vs. embedding them in every page.  For HTTP, separate should be faster (it can be cached), HTTPS, embedding should be faster (it's one less request).

Don't forget the server side.  Most of the projects I've had to fix on have been slow waiting for the server to read the same data from the database 3 or 4 times, and then throw it away and use different data to build the screen!

You can experiment with having your web server compress responses.  I think there's a gzip compression option on most servers that browsers understand.

If you have a big image (with HTTP), use the same big image on every page so the browser can cache it.

Learn the differences between GIF, PNG, and JPEG.  Each works best for a different type of image.  If you have a large, very faded background, you can compress the heck out of it in a really low-quality JPEG and if the contrast is low enough in the original image, it will look fine.

Compress your CSS.  I've had good luck with lotterypost.com/css-compress.aspx recently.  I do add a line break after ever } so I can still read it.

Eliminate unused CSS, comments, whitespace...  I always put a line break after a
 and you can't always trim whitespace from inside  elements without causing trouble.  But you can remove consecutive whitespace characters anywhere.

Write simple HTML.  Use fewer tables, fewer tags, less formatting whenever possible.  A strong knowledge of HTML and CSS is your biggest ally here.

Don't use spacer images (from my blog).

These suggestions work with any major platform.  I might look for something that gives you a lot of control over your HTML.  I'd stay away from JSP and Struts tags due to the difficulty of managing whitespace.  If you are into Java, you could look at JRebel to automatically compile servlets, but most people use Spring with JSF, which I haven't tried.  Ruby/Rails is great for rapid prototypes, but not for your final application.  A good portion of the web runs on PHP, so how bad can it be?  I'm into Scala these days, and have been meaning to check out Lift (for secure sites).  Play looks pretty sweet to me for a public site, but as I said, I'm a little biased towards Scala right now.  There are so many choices!

Good luck!

Body:
I think Watson needs to qualify his point #5: Minimize JavaScript.  I think what he means with is point #3 is if you have a page that needs to build a lot of HTML around a list of very small bits of data, you can build the data into an array in JavaScript and have it build that part of the page using Document.write().  For instance, on a page that has to list many long strings separated by commas or by semicolons, you could just list the strings once.

var emailAddrs = new Array("address1@nowhere.com",
    "address2@nowhere.com",
    ...
    "addressN@nowhere.com");
function showEmailAddrs(semicolon) {
    var innerHtml = '<a href="mailto:javascript:hideEmailAddrs();">Hide email addresses<\/a><br \/>\n<span class="normal">';
    if (semicolon) {
        innerHtml += emailAddrs.join('; ');
    } else {
        innerHtml += emailAddrs.join(', ');
    }
    innerHtml += '<\/span>';
    document.getElementById("emailAddrs").innerHTML = innerHtml;
}

With a long list, you can see how this would save almost half the size.  If the JavaScript built <option value="123"> tags around a few thousand strings, you can save even more space.  As others have said, avoid large images.  I would also have to add:

Theories only get you so far.  Believe what you time, and time everything.  I like to make each timing test 10 times, arrange the results in ascending order and average the middle two times.  Record your time before you start optimizing so you are sure that you are making things better and not worse.  I time the server, I time the client...  you get the picture.

Use the built-in timers in the "Developer Tools" in most browsers.

Don't use HTTPS unless you have to - it turns off browser caching.

Time the difference between using separate CSS and JavaScript files vs. embedding them in every page.  For HTTP, separate should be faster (it can be cached), HTTPS, embedding should be faster (it's one less request).

Don't forget the server side.  Most of the projects I've had to fix on have been slow waiting for the server to read the same data from the database 3 or 4 times, and then throw it away and use different data to build the screen!

You can experiment with having your web server compress responses.  I think there's a gzip compression option on most servers that browsers understand.

If you have a big image (with HTTP), use the same big image on every page so the browser can cache it.

Learn the differences between GIF, PNG, and JPEG.  Each works best for a different type of image.  If you have a large, very faded background, you can compress the heck out of it in a really low-quality JPEG and if the contrast is low enough in the original image, it will look fine.

Compress your CSS.  I've had good luck with lotterypost.com/css-compress.aspx recently.  I do add a line break after ever } so I can still read it.

Eliminate unused CSS, comments, whitespace...  I always put a line break after a <br /> and you can't always trim whitespace from inside  elements without causing trouble.  But you can remove consecutive whitespace characters anywhere.

Write simple HTML.  Use fewer tables, fewer tags, less formatting whenever possible.  A strong knowledge of HTML and CSS is your biggest ally here.

Don't use spacer images (from my blog).

These suggestions work with any major platform.  I might look for something that gives you a lot of control over your HTML.  I'd stay away from JSP and Struts tags due to the difficulty of managing whitespace.  If you are into Java, you could look at JRebel to automatically compile servlets, but most people use Spring with JSF, which I haven't tried.  Ruby/Rails is great for rapid prototypes, but not for your final application.  A good portion of the web runs on PHP, so how bad can it be?  I'm into Scala these days, and have been meaning to check out Lift (for secure sites).  Play looks pretty sweet to me for a public site, but as I said, I'm a little biased towards Scala right now.  There are so many choices!

Good luck!


问:
In what order do people build websites?
For a website, you need to have an idea, you need to have a design and you need to have data, events and output, right? Whether it be a blog, web app, Q&A site, search engine...

Anyway, that is only slightly related to my question. My question is, when designing a website, providing I know the purpose, what should I start with?

Should I start with the CSS, design and look&feel using dummy data first, or should I program in the logic, events and output, and style it later? What is the design process of most websites that are built from the ground up?

答:
Your first concern should be the content that will be on the website. A good notion to Google for is 'Content First'. (Here's an article discussing working on your content in tandem with your structure: http://www.markboulton.co.uk/journal/structure-first-content-always)

For actually building the site, I feel that it is better to get the functionality (logic, events, output) that you mentioned in place and then move on to CSS and prettying it up. (I work as a front-end web developer)

The important thing is to plan out what you are going to be building before you hop in and start slinging code around. Your logic should be based on a spec and your CSS should be based on comps and wireframes, and all that should be based on communication with your client and what needs they have for the site.

Title: In what order do people build websites?


答:
If you are implementing a web site for a client, start with wire-frames.  Unless your client is an experienced web developer or web designer, they will have zero ability to envision anything on the web.  You have to show them exactly what they will see, or something that is obviously a drawing of a web page.  Try to get them to speak to you about how the site will be used and construct some user scenarios or "use cases" from that.

When you feel you know what is required, and it's going to be an interactive site, I like to design the database first because it's the most "upstream" part of the application - everything else depends on it.  Good design decisions there make the rest of your job much easier (and vice-versa).  If you are making a blog or content management system, maybe it's just a matter of choosing a NoSQL database.

Once the database design looks good, I go back to my wireframes and implement them in HTML.  The last phase is to write the middleware that queries the data from the database and builds the HTML for the screens.

The actual order varies for different projects and there is always back-and-forth where a design decision somewhere sends you to a different part of the application to compensate, but this is a pretty good default plan to start from.

To Summarize:

Gather Requirements

Design Database

Start front-end (HTML etc.)

Make middle "Business Logic" to connect front-end to Database.

Reading this over, I'd have to recommend that you write test cases for your business logic as you code it.  Then when you need to change something you have a way to verify that everything else still works.  Some front-end testing needs to be done manually.  Use an HTML validator and test (manually as a user) on several different brands of browsers.

Title: In what order do people build websites?

Body:
For a website, you need to have an idea, you need to have a design and you need to have data, events and output, right? Whether it be a blog, web app, Q&A site, search engine...

Anyway, that is only slightly related to my question. My question is, when designing a website, providing I know the purpose, what should I start with?

Should I start with the CSS, design and look&feel using dummy data first, or should I program in the logic, events and output, and style it later? What is the design process of most websites that are built from the ground up?


问:
Using Mock for event listeners in unit-testing
I keep getting to test this kind of code (language irrelevant) :

```<code>public class Foo() {

   public Foo(IDependency1 dep1) {
      this.dep1 = dep1;
   }

   public void setUpListeners() {
      this.dep1.addSomeEventListener(.... some listener code ...);
   }
}
</code>```

Typically, you want to test what when the dependency fires the event, the class under tests reacts appropriately (in some situation, the only purpose of such classes is to wire lots of other components, that can be independently tested.

So far, to test this, I always end up doing something like :

creating a 'stub' that implements both a addXXXXListener, that simply stores the callback, and a fireXXXX, that simply calls any registered listener. This is a bit tedious since you have to create the mock with the right interface, but that can do

use an introspective framework that can 'spy' on a method, and inject the real dependency in tests

Is there a cleaner way to do this kind of things ?

EDIT : to clarify what I mean, my trouble is that if I could write something like this :

```<code>public class FooTest() {

  public void testListensToDependencies() {

   IDependency mockDependency = createMock(IDependency.class)

   Foo tested = new Foo(mockDependency);
   tested.setUpListeners();

   expect(mockDependency.addSomeEventListener).toHaveBeenCalled();

  }
}
</code>```

However, obviously this test would pass no matter what the listener does. This is troubling me, since I want to test that I am wiring my objects to do the proper thing.

The next best thing would be :

public class Foo() {

```<code>  public Foo(IDependency1 deps) { .... }

  public void setUpListeners() {

     // In a language with first class function :
     this.dep1.addSomeEventListener(this.handleSomeEvent);

     // In a language without it :
     this.dep1.addSomeEventListener(new Foo.SomeEventHandler());
  }
</code>```

And then I would write tests to :

check that the 'addSomeEventListener' was called either with the right handler function, or with an instance of the right event handler class

check that the handler function, or the event handler class, actually implement the expected behavior.

Now I am not sure if that would be clearer, or if it is the sign I'm wiring my objects at the wrong place....

答:
When you are unit testing class Foo, you should only go so far as to check that

a) add listener is called on your mock and
b) the event is fired on the mock

After all, when you are unit testing class foo, you shouldn't care what your dependant class (Dependency1 in your example) is doing internally. Otherwise you are testing more than the unit Foo. Mocking frameworks, for example, Moq will typically provide you with
a way to assert that a given method is called on your mock, you can even assert the number of times that you expect the method to be called.

here is rough example using Moq in C# (haven't compiled this it's just to give an idea)

```<code>var depMock = new Mock<Dependancy1>();
var foo = new Foo(depMock.Object);
foo.setUpListeners();
//verify that addSomeEventListener was called
depMock.Verify(x=>x.addSomeEventListener);
foo.doSomethingThatShouldRaiseEvent();
//verify that event is called
depMock.Verify(x=>x.underlyingMethodOnDependency());
</code>```

It is your unit testing of Dependency1 that should verify it's internal behaviour.

OwnerDisplayName: phtrivier

Body:
When you are unit testing class Foo, you should only go so far as to check that

a) add listener is called on your mock and
b) the event is fired on the mock

After all, when you are unit testing class foo, you shouldn't care what your dependant class (Dependency1 in your example) is doing internally. Otherwise you are testing more than the unit Foo. Mocking frameworks, for example, Moq will typically provide you with
a way to assert that a given method is called on your mock, you can even assert the number of times that you expect the method to be called.

here is rough example using Moq in C# (haven't compiled this it's just to give an idea)

var depMock = new Mock<Dependancy1>();
var foo = new Foo(depMock.Object);
foo.setUpListeners();
//verify that addSomeEventListener was called
depMock.Verify(x=>x.addSomeEventListener);
foo.doSomethingThatShouldRaiseEvent();
//verify that event is called
depMock.Verify(x=>x.underlyingMethodOnDependency());

It is your unit testing of Dependency1 that should verify it's internal behaviour.


问:
Storing and analyzing rock climbing difficulty
I'm working on a WordPress plugin to manage rock climbing data, and I need to think of a way to store rock climbing grades from all of the different systems in a unified way. There are many different systems, all of which have some numerical system.

A comparison of all the systems: http://en.wikipedia.org/wiki/Grade_(climbing)#Comparison_tables

Is there some unified way that I can store and analyze these, or do I just need to assign numbers to them all and call it a day? My current plan is to save the score type and then assign each score a numerical value, which I can then use to compare and graph them.

答:
If you can be certain that grades in the different systems are exactly equivalent, then you can of course come up with a table that lets you convert from one grade to another. That seems unlikely, though -- the Wikipedia article you linked says:

no two grading systems have an exact one-to-one correspondence

So it seems like you should just go ahead and store whatever grade or grades have been assigned to a given route. You can still use a table to convert each grade to some sort of common scale for the purposes of comparison and graphing, but I wouldn't try to be too precise about it. From my own experience, I agree with the article that grading is pretty subjective. Climbers come in different shapes and sizes and have different approaches to climbing, so two people may not agree on the relative difficulty of routes.


问:
Clarify the Single Responsibility Principle
The Single Responsibility Principle states that a class should do one and only one thing.  Some cases are pretty clear cut.  Others, though, are difficult because what looks like "one thing" when viewed at a given level of abstraction may be multiple things when viewed at a lower level.  I also fear that if the Single Responsibility Principle is honored at the lower levels, excessively decoupled, verbose ravioli code, where more lines are spent creating tiny classes for everything and plumbing information around than actually solving the problem at hand, can result.

How would you describe what "one thing" means?  What are some concrete signs that a class really does more than "one thing"?

答:
I always view it on two levels:

I make sure my methods only do one thing and do it well

I see a class as a logical (OO) grouping of those methods that represents one thing well

So something like a domain object called Dog:

Dog is my class but Dogs can do many things! I might have methods such as walk(), run() and bite(DotNetDeveloper spawnOfBill) (sorry couldn't resist ;p).

If Dog becomes to unwieldy then I'd think about how groups of those methods can be modeled together in another class, such as a Movement class, which could contain my walk() and run() methods.

There's no hard and fast rule, your OO design will evolve over time.  I try to go for a clear cut interface/public API as well as simple methods that do one thing and one thing well.


问:
How do operating systems… run… without having an OS to run in?
I'm really curious right now. I'm a Python programmer, and this question just boggled me: You write an OS. How do you run it? It has to be run somehow, and that way is within another OS?

How can an application run without being in an OS? How do you tell the computer to run, say, C, and execute these commands to the screen, if it doesn't have an OS to run in?

Does it have to do with a UNIX kernel? If so, what is a Unix kernel, or a kernel in general?

I'm sure OSes are more complicated than that, but how does it work?

答:
There are plenty of websites that go through the boot process (such as How Computers Boot Up). In a nutshell, its a multi-stage process that keeps building up the system a little bit at a time until it can finally start the OS processes.

It starts with the firmware on the motherboard which tries to get the CPU up and running. It then loads up the BIOS which is like a mini operating system that gets the other hardware up and running. Once that is done it looks for a boot device (disk, CD, etc) and, once found, it locates the MBR (master boot record) and loads it into memory and executes it. It's this little piece of code that then knows how to initialize and start the operating system (or other boot loaders as things have gotten more complicated). It's at this point that things like the kernel would be loaded and start running.

It's pretty incredible that it works at all!


答:
A "bare metal" operating system doesn't run within anything.  It runs the full instruction set on the physical machine, and has access to all of physical memory, all device registers and all privileged instructions, including those that control the virtual memory support hardware.

(If the operating system is running on a virtual machine, it may think it is in the same situation as above.  The difference is that certain things are emulated or in some other way handled by the hypervisor; i.e. the level that runs the virtual machines.)

Anyway, while the OS might be implemented in (for example) C, it won't have all of the normal C libraries available to it.  In particular, it won't have the normal 'stdio' libraries.  Rather, it will implement (for example) a disk device driver that allows it to read and write disk blocks.  It will implement a file system on top of the disk block layer, and on top of that it will implement the system calls that a user application's runtime libraries make to (for example) create, read and write files ... and so on.

How can an application run without being in an OS?

It needs to be a special kind of application (e.g. an operating system) that knows how to interact directly with the I/O hardware, etc.

How do you tell the computer to run, say, C, and execute these commands to the screen, if it doesn't have an OS to run in?

You don't.

The application (which was for the sake of argument written in C) is compiled and linked on some other machine to give a native code image.  Then the image is written to the hard drive in a place that the BIOS can find it.  The BIOS loads the image into memory, and executes an instruction to jump to the application's entry point.

There (typically) isn't any "running C and executing commands" in the application unless it is a full-blown operating system.  And in that case, it is the operating system's responsibility to implement all of the required infrastructure to make it happen.  No magic.  Just lots of code.

Bill's answer covers bootstrapping which is the process in which you go from a powered-off machine to a machine in which the normal operating system is up and running.  However, it is worth noting that when the BIOS completes its tasks, it (typically) gives over complete control of the hardware to the main operating system, and plays no further part — until the next system restart.  The main OS is certainly not running "within" the BIOS in the conventional sense.

Does it have to do with a UNIX kernel? If so, what is a unix kernel, or a kernel in general?

Yes it does.

The UNIX kernel is the core of the UNIX operating system.  It is the part of UNIX that does all of the "bare metal" stuff described above.

The idea of a "kernel" is that you try to separate the system software into core stuff (that requires physical device access, all of memory, etc), and non-core stuff.  The kernel consists of the core stuff.

In reality, the distinction between kernel/core and non-kernel/non-core is more complicated than that.  And there has been a lot of debate over what really belongs in a kernel, and what doesn't.  (Look up micro-kernel for example.)

Title: How do operating systems… run… without having an OS to run in?

Body:
I'm really curious right now. I'm a Python programmer, and this question just boggled me: You write an OS. How do you run it? It has to be run somehow, and that way is within another OS?

How can an application run without being in an OS? How do you tell the computer to run, say, C, and execute these commands to the screen, if it doesn't have an OS to run in?

Does it have to do with a UNIX kernel? If so, what is a Unix kernel, or a kernel in general?

I'm sure OSes are more complicated than that, but how does it work?


问:
Why is the use of abstractions (such as LINQ) so taboo?
I am an independent contractor and, as such, I interview 3-4 times a year for new gigs.  I am in the midst of that cycle now and got turned down for an opportunity even though I felt like the interview went well.  The same thing has happened to me a couple of times this year.

Now, I am not a perfect guy and I don't expect to be a good fit for every organization.  That said, my batting average is lower than usual so I politely asked my last interviewer for some constructive feedback, and he delivered!

The main thing, according to the interviewer, was that I seemed to lean too much towards the use of abstractions (such as LINQ) rather than towards lower-level, organically grown algorithms.

On the surface, this makes sense--in fact, it made the other rejections make sense too because I blabbed about LINQ in those interviews as well and it didn't seem that the interviewers knew much about LINQ (even though they were .NET guys).

So now I am left with this question: If we are supposed to be "standing on the shoulders of giants" and using abstractions that are available to us (like LINQ), then why do some folks consider it so taboo?  Doesn't it make sense to pull code "off the shelf" if it accomplishes the same goals without extra cost?

It would seem to me that LINQ, even if it is an abstraction, is simply an abstraction of all the same algorithms one would write to accomplish exactly the same end.  Only a performance test could tell you if your custom approach was better, but if something like LINQ met the requirements, why bother writing your own classes in the first place?

I don't mean to focus on LINQ here.  I am sure that the JAVA world has something comparable, I just would like to know why some folks get so uncomfortable with the idea of using an abstraction that they themselves did not write.

UPDATE

As Euphoric pointed out, there isn't anything comparable to LINQ in the Java world.  So, if you are developing on the .NET stack, why not always try and make use of it?  Is it possible that people just don't fully understand what it does?

答:
This one got a bit long, but it might be helpful to someone so I'll let it be.

I actually encountered something similar, going through a little over 20 interviews last month (a mix of phone and face to face). There definitely was something unexpected going on that I couldn't quite put my finger on.

One of the things I noticed though was that the things that have usually been the center-point of the interview cycles of the past five or six years were decidedly not discussed or given short shrift. Things like the fundamentals of OOP analysis / design, patterns (design and architectural both), some of the more advanced / abstraction oriented .net features (including lambdas or LINQ specifically, generics, serialization / data binding, and similar), and even the usually hot topic of favored methodology (no one seemed to care much about agile vs waterfall or what flavor of agile) and tools or choice of ORM or preferred means of collaboration or source control management. In some cases not mentioned at all, in almost all cases apparently not of concern.

What did receive focus, in multiple interviews and various unrelated firms in unrelated industries, were along these lines:

A strange fixation on outdated / outmoded conventions and "back to stone ages" limitations. Like developing a primitive web app in VS2003 with a list of absurd restrictions further forbidding the usage of explicit features extent within that era of .net...as if that is a real gauge of a modern developers ability...the ability to remember the paradigm and limitations of 9 years ago further crippled by unrealistic / arbitrary constraints. Another place was very dogged on the subject of custom collections, circa pre-generic collections. Another place dinged a code sample of a class model I scrawled out because I didn't use cascaded constructors (they seemed unaware of the support for property initialization on declaration, which was sufficient to the need). Another place was big on delegates and did not like my response that I used to declare them frequently but I practically never need to declare them anymore thanks to Action<> and Func<>.

Extreme focus on specific implementation details in a microcosm and / or configuration settings, even in the case of technologies that focus on being platform or protocol agnostic (i.e...the whole point is to NOT be fixated on a specific implementation or particular usage but rather on reuse / re-purposing / extensibility / as needed integration).

Willingness to spec out / supervise / code review / and otherwise spool off work to and from an off shore team, and non-coding skills related to doing so.

Usage of specific versions of products / platforms / modules / etc. To a sometimes absurd degree; "So...you've used versions 1, 2, and 4? But not 3, eh? Hmmm...{annotates your resume with "no v3!!!}". Degree of usage did not seem to matter; only that you have or have not used something at all, and the specific thing that they are asking for also...no substitutions seemed to count, even of a more widely used and fully featured competing product.

A far greater amount of focus on "how well will you fit onto our team" over "are you actually any good as a software developer" or "do you have the skills and experience to add value to the company and help us deliver a quality product" or even "are you a dangerous idiot who will come in and wreck shop". In some cases, my resume was just taken as a given, and even the so-called "tech screen" or technical interview was a personality assessment far more than a skills assessment. Even for relatively short term contract positions where you would be there and gone again before two seasons have changed.

Companies this time around seemed to have much less of a focus on solving specific technical problems, starting new green-field or big 2.0 development projects, or getting a specific product to market to capitalize on an emergent trend or opportunity, or the usual big kickoffs. A repeating theme that I noticed at at least 15 of the places was that a small group of 3-5 developers, mostly survivors of the market crash in 08, were able to grind out a product over the course of the last 3 years or so and found some success or their company as a whole is booming and they are hiring on new folks to keep up with increasing feature demands or to address / overcome the design flaws they built in to these systems, or to take over the aforementioned platforms to free up the core team that built it to do "other projects". The details differed and there were exceptions, but that was the general lay of the land this time around.

But...if there's one thing I know about this business it's that it is cyclical. The next time I'm looking for a new gig, I wont be surprised if the game has changed yet again. You just have to remain mentally flexible, do some active listening, avoid making absolute statements if they are unnecessary but don't be a weasel either, and don't come off as being either one-dimensional (you come of as an idiot or a zealot, neither desirable) or as being too good (it can be threatening and cost you a gig).

Just adjust your approach, and try to give a more measured response next time...mention a few different ways you might approach a problem...but even if it is rote knowledge for you act as if you are actually thinking about it and reasoning it out on the spot. It seems more humble and less intimidating or offputting that way.

Of course, Murphy's Law being what it is, the very next interview after you stop being "passionate about my current favorite technology guy" and adopt a more balanced / beard-stroking stance is the gig that you would have gotten had you been the crazed zealot guy.  ;)


问:
Author's work and copyright. in UI design
Typical situation in UI design: you do design of some UI and, say, came up with some bright new idea like "ribbon" or "kinetic scroll past end".

What would be the strategy about such thing? Register patent, don't like it, but anyway would like to ask: how long it takes to do all this stuff and how much it will cost in average?

If to forget about patents, will the idea have something like "prior art" status or some such if someone will try to patent this in future?

All this about project / product published by solo developer.

答:
You should read about the concept of prior art in Wikipedia. In essence, it would work, but let me highlight this:

[Prior art] constitutes all information that has been made available to the public in any form before a given date that might be relevant to a patent's claims of originality. If an invention has been described in the prior art, a patent on that invention is not valid.

So, you can avoid patents over your work if those patents are registered after you’ve already done something about it. However, it must be something public. Later on you can read:

Prior art must be available in some way to the public, and in many countries, the information needs to be recorded in a fixed form somehow.


问:
Proper response for a REST insert - full new record, or just the record id value?
I'm building a REST API which allows inserts (POST, not idempotent) and updates (PUT, idempotent) requests to add/update database to our application.

I'm wondering if there are any standards or best practices regarding what data we send back to the client in the response for a POST (insert) operation. We need to send back at least a record ID value (e.g. your new record is record #1234).

Should we respond with the full object? (e.g. essentially the same response they'd get back from a "GET /object_type/1234" request)

Should we respond with only the new ID value? (e.g. "{ id: 1234 }", which means that if they want to fetch the whole record they need to do an additional HTTP GET request to grab the full record)

A redirect header pointing them to the URL for the full object?

Something else entirely?

答:
Well, in a REST interface, following HTTP where ever possible, I would return a 201 and an URI in the Location header field to the newly created Resource. Here is what Status Code Definitions says:

10.2.2 201 Created

The request has been fulfilled and resulted in a new resource being
  created. The newly created resource can be referenced by the URI(s)
  returned in the entity of the response, with the most specific URI for
  the resource given by a Location header field. The response SHOULD
  include an entity containing a list of resource characteristics and
  location(s) from which the user or user agent can choose the one most
  appropriate. The entity format is specified by the media type given in
  the Content-Type header field. The origin server MUST create the
  resource before returning the 201 status code. If the action cannot be
  carried out immediately, the server SHOULD respond with 202 (Accepted)
  response instead.

If something went wrong, I would argue you shouldn't return -1 as others have said, but simply a Client or Server Error Code (4xx or 5xx). For example, if a user is not allowed to create some new resource, you would simply return a "401 Unauthorized", nothing more and nothing less.


问:
Is Java free/open source or not?
On November 13, 2006, Sun released much of Java as free and open source software, (FOSS), under the terms of the GNU General Public License (GPL). On May 8, 2007, Sun finished the process, making all of Java’s core code available under free software/open-source distribution terms, aside from a small portion of code to which Sun did not hold the copyright.

OpenJDK (Open Java Development Kit) is a free and open source implementation of the Java programming language. It is the result of an effort Sun Microsystems began in 2006. The implementation is licensed under the GNU General Public License (GNU GPL) with a linking exception.

Why there are still people who say that Java is not open source or free as in free speech?

Am I missing something?

Is Java still proprietary?

答:
The problem is that in order to call something "Java" you need to get it certified as compliant to the Java spec.

One of the pre-requisites of getting this certification is running you JVM through a test suite - Java Technology Compatibility Kit (TCK). This test suite is NOT open sourced.

So you can build a JVM that behaves in a very Java like way and be completely open source, but, if you want to call it a "Java JVM" you need to buy the certification suite under a non open source license. To many open source advocates this is a complete non starter.

Title: Is Java free/open source or not?


答:
You should have read this answer before it was removed about which one to use. The main answer stated:

About Java 7, note that JDK7 and OpenJDK7 will have (nearly) identical code base.

Notice the nearly I highlighted.

From the article linked from that answer:

[…] but there is some code where there are open source replacements where we still use the old closed source code. This is primarily in font and graphics rasterization. The old closed source rasterisation code, while being encumbered, has had 10+ years of bug fixing and fine tuning etc and, for any open source replacement to displace that code in productized JDK builds, it would have to be provably as fast and stable and good quality as the existing closed code.

Also, from the Java FAQ:

The Java Development Kit (JDK) is free to download and use for commercial programming, but not to re-distribute.

So, not open source. Just nearly.

Also, even if it were completely open source, the development model and governance would not. That is not a licensing concern, though.

Title: Is Java free/open source or not?

Body:
On November 13, 2006, Sun released much of Java as free and open source software, (FOSS), under the terms of the GNU General Public License (GPL). On May 8, 2007, Sun finished the process, making all of Java’s core code available under free software/open-source distribution terms, aside from a small portion of code to which Sun did not hold the copyright.

OpenJDK (Open Java Development Kit) is a free and open source implementation of the Java programming language. It is the result of an effort Sun Microsystems began in 2006. The implementation is licensed under the GNU General Public License (GNU GPL) with a linking exception.

Why there are still people who say that Java is not open source or free as in free speech?

Am I missing something?

Is Java still proprietary?


问:
Check-list to avoid vendor lock-in?
Is there a set of industry-approved rules to avoid vendor lock-in?

I mean, something one can show to a manager, or other decision maker, that is easy to understand and easily verifiable.

Are there any universally accepted set of rules, a checklist or set of conditions that helps detect and prevent vendor lock-in in an objective, measurable way?

Have any of you warned a manager about the risk of vendor lock-in during the initial stages of a project?

答:
These are some guidelines I use when evaluating lock in:

Does the vendor use industry standard formats?

If you end up with tons of files and code that has to speak a foreign language, then switching is exceedingly difficult. If you have standard formats like XML and JSON not so. For instance ASP .Net uses aspx, which is markup that is neither html, nor is it valid XML. This makes it very difficult to convert those files or parse them.

Does the vendor supply sufficient points to integrate with their system?

Can you liberate your data out of the system, and integrate it with your own systems sufficiently via some form of interoperation, like web services? If you want to integrate it with your systems do you need to add more vendor products at a premium?

How hard is it to change out the solution for another one?

A constant sanity check is needed to see how difficult it would be to move away from the vendor. If the vendor's stuff pervades your entire infrastructure you should be weary.

Title: Check-list to avoid vendor lock-in?