问:
Can I get a C++ Compiler to instantiate objects at compile time
I am writing some code that has a very large number of reasonably simple objects and I would like them the be created at compile time.  I would think that a compiler would be able to do this, but I have not been able to figure out how.

In C I could do the the following:

```<code>#include <stdio.h>

typedef struct data_s {
    int a;
    int b;
    char *c;
} info;

info list[] = {
    1, 2, "a",
    3, 4, "b",
};

main()
{
   int i;
   for (i = 0; i < sizeof(list)/sizeof(*list); i++) {
     printf("%d %s\n", i, list[i].c);
   }
}
</code>```

Using #C++* each object has it constructor called rather than just being layed out in memory.

```<code>#include <iostream>
using std::cout;
using std::endl;

class Info {
    const int a;
    const int b;
    const char *c;
public:
    Info(const int, const int, const char *);
    const int get_a() { return a; };
    const int get_b() { return b; };
    const char *get_c() const { return c; };
};

Info::Info(const int a, const int b, const char *c) : a(a), b(b), c(c) {};

Info list[] = {
    Info(1, 2, "a"),
    Info(3, 4, "b"),
};

main()
{
    for (int i = 0; i < sizeof(list)/sizeof(*list); i++) {
        cout << i << " " << list[i].get_c() << endl;
    }
}
</code>```

I just don't see what information is not available for the compiler to completely  instantiate these objects at compile time, so I assume I am missing something.

答: Who says the compiler isn't doing exactly what you want? In the code shown, a compliant compiler may compile your List code to the same assembly as the C code.


问:
Is it dangerous for me to give some of my Model classes Control-like methods?
In my personal project I have tried to stick to MVC, but I've also been made aware that sticking to MVC too tightly can be a bad thing as it makes writing awkward and forces the flow of the program in odd ways (i.e. some simple functions can be performed by something that normally wouldn't, and avoid MVC related overheads).

So I'm beginning to feel justified in this compromise:

I have some 'manager programs' that 'own' data and have some way to manipulate it, as such I think they'd count as both part of the model, and part of the control, and to me this feels more natural than keepingthem separate. For instance: One of my Managers is the PlayerCharacterManager that has these methods:

```<code>void buySkill(PlayerCharacter playerCharacter, Skill skill);
void changeName();
void changeRole();
void restatCharacter();
void addCharacterToGame();
void createNewCharacter();
PlayerCharacter getPlayerCharacter();
List<PlayerCharacter> getPlayersCharacter(Player player);
List<PlayerCharacter> getAllCharacters();
</code>```

I hope the mothod names are transparent enough that they don't all need explaining.

I've called it a manager because it will help manage all of the PlayerCharacter 'model' objects the code creates, and create and keep a map of these. I may also get it to store other information in the future.

I plan to have another two similar classes for this sort of control, but I will orchestrate when and how this happens, and what to do with the returned data via a pure controller class. This splitting up control between informed managers and the controller, as opposed to operating just through a controller seems like it will simplify my code and make it flow more.

My question is, is this a dangerous choice, in terms of making the code harder to follow/test/fix? Is this somethign established as good or bad or neutral? I oculdn't find anything similar except the idea of Actors but that's not quite why I'm trying to do.

Edit: Perhaps an example is needed; I'm using the Controller to update the view and access the data, so when I click the 'Add new character to a player button' it'll call methods in the controller that then go and tell the PlayerCharacterManager class to create a new character instance, it'll call the PlayerManager class to add that new character to the player-character map, and then it'll add this information to the database, and tell the view to update any GUIs effected. That is the sort of 'control sequence' I'm hoping to create with these manager classes.

答:
It is in general dangerous to mix things that have proven good to be split, as is also the case of mixing application control and domain model.

But it is not the case of your example. You 'player manager' class (I would call it Team or Game, but I don't know the others), is perfect part of the Model.

As was already mentioned, you have probably too 'database-driven' view. Try to forget about data(base)'s central role - it is just the persistence engine, nothing more. It is not the centre, it is a service.

Model contains all the logic of your application (logic, not data; that it in fact must contain (that is, manipulate and return) some data, is just the derived from the fact it contains the logic). One thing that Model may depend upon is a persistency service, eg. database.

So Model is primarily API, not data. So your example is a perfect fit into the Model.

View is, hopefully, clear -- this is the one that presents parts of the Model to the user.

Controller (or other things in MV* class of patterns, like Presenter in MVP or View Model in MVVM) are the hardest to catch. Classical Controller in MVC is the one that reacts to (user) events and manipulates the Model (consequently, the view updates).

So your example is definitely not the Controller.

ContentLicense: CC BY-SA 3.0


问:
Calculations in Vector Register
How do vector registers work in terms of calculations and alloting data to them ?
Is there a detailed reference available somewhere explaining how vector registers work and how data is fetched from them ?</p>

答: Well, one of the earliest vector registers was the H/L register pair. I think that dates back to the 8080, perhaps the 8008. In the end, a vector register is nothing very special. Instructions still need to specify input register(s), output register(s), and operations. On a silicon level, it means that one operation is dispatched multiple times with different registers, usually in parallel.</p>

Title: Calculations in Vector Register


问:
Integrating with a payment provider; Proper and robust OOP approach

History

We are currently using a so called redirect model for our online payments (where you send the payer to a payment gateway, where he inputs his payment details - the gateway will then return him to a success/failure callback page). That's easy and straight-forward, but unfortunately quite inconvenient and at times confusing for our customers (leaving the site, changing their credit card details with an additional login on another site etc).

Intention & Problem description

We are now intending to switch to an integrated approach using an exchange of XML requests and responses. My problem is on how to cater with all (or rather most) of the things that may happen during processing - bearing in mind that normally simplicity is robust whereas complexity is fragile.

Examples

User abort: The user inputs Credit Card details and hits submit. An XML message to the provider's gateway is sent and waiting for response. The user hits "stop" in his browser or closes the window.

ignore_user_abort() in PHP may be an option - but is that reliable?

might it be better to redirect the user to a "please wait"-page, that in turn opens an AJAX or other request to the actual processor that does not rely on the connection?

Database goes away

sounds over-complicated, but with e.g. a webserver in the States and a DB in the UK, it has happened and will happen again: User clicks together his order, payment request has been sent to the provider but the response cannot be stored in the database. What approach could I use, using PHP to sort of start an SQL like "Transaction" that only at the very end gets committed or rolled back, depending on the individual steps? Should then neither commit or roll back have happened, I could sort of "lock" the user to prevent him from paying again or to improperly account for payments - but how?

And what else do I need to consider technically? None of the integration examples of e.g. Worldpay, Realex or SagePay offer any insight, and either my search engine or my search terms weren't good enough to find somebody else's thoughts on this.

Thank you very much for any insight on how you would approach this!

答:
As a developer working almost exclusively with payments I perhaps can give you some pointers about where the possible pitfalls are. I'm working for a site with high traffic, ~40 active payment service providers (PSPs) and dealing with tens of thousands transactions per day. And trust me, the sh*t will always hit the fan and all you can do is prepare as much as possible for dealing with the situation from that point.

Log, log and log some more...

This is the most important part in your payment process, make sure you have a record of everything. Ask yourself the questions "could this piece of information help me once in a million transactions?". If the answer is yes, log it!

Our setup is that the main point of logging is the database. Every initiated, failed, settled, redirected, etc transaction is stored per PSP in tables. If the PSP uses an API, all API-calls are logged (both requests sent and responses). All callbacks are logged in tables as well. And so forth..

When we encounter an unexpected event or exception we log it to the PHP log file with a certain format to make it searchable and easily found based on transaction ID, user ID, etc.

You will be grateful that you have all the data if you get sued for example.

Monitoring and alerts

Build in monitoring logic with some simple tests that will alert you through email when something goes wrong. For example, if 3 callbacks in a row fails for a PSP. All of these small things that can make you work on resolving issues quickly instead of reacting to them after your customers have made you aware of them (which doesn't always happen) is very important.

Database transactions

If you have the luxury of setting up or changing your database structure to support database transactions, for example use InnoDB on MySQL. Take a look at this answer on how to handle it in the code. You should make sure that every step of a transaction is completed or none is, having partially completed transactions is just a burden on you and your system. For example: 1) User completes transaction, 2) User gets rewarded somehow. If not both step 1 and 2 are met here, the transaction should not be set as complete in step 1.

Technical people to contact

When you have a technical issue, make sure you have someone technical to contact immediately. Having an account manager is pretty useless, especially if that person decides to mediate between you and their technician.

Live world example that happened to me: one PSP all of the sudden stops working, nothing in our code had changed and they say they haven't changed anything as well. After sending debug information back and forth with them (through their account manager), one of their technicians catches that the WSDL-schema fetches seems off. Then they realize they updated their WSDL-schema and after some debugging I realize that PHP cached the old WSDL-schema. This could've been caught sooner as resolved if I just had a technical person on Skype to contact directly. Or if they just admitted to changing their WSDL-schema, but it's often hard to get a confession out of the PSPs when something goes wrong..

Final words...

Prepare all you can and assume that ANYTHING can happen :)

Not sure this was exactly the kind of answer you were after, but I'm trying to provide a real world example of payments and how you can prevent the biggest traps and pitfalls. Let me know if there's something you would like me to elaborate on or if you're interested in another topic.


问:
Is it possible to use RubyGnome2's/QtRuby's HTML renderers to make UI for a Ruby script?
I'd like to make a graphical user interface for my script, instead of running it from the console. I'm aware there's a wealth of UI libraries for Ruby, but I'm quite familiar with HTML and CSS and I'd like to use them for building an interface. So the question is:

Is it possible to use a HTML rendering library to make such an UI? From what I understand, it's relatively easy to put in a HTML rendered view of something, but is it possible to communicate back with the script? Like when I push that big red button, it actually tells the script to act on it? Obviously it's possible if the script run on the server side, but I'd like to run it as a desktop application.

答:
Qt has a Webkit module.  You should be able to create a a UI using those to do what you want.

Here is an example of a dynamic page using QtRuby

```<code>require 'Qt4'
require 'qtwebkit'

class A < Qt::WebView
  slots 'mySlot(QUrl)'
  def initialize()
super()
connect(self, SIGNAL('linkClicked(QUrl)'), self, SLOT('mySlot(QUrl)'))
  end
  def mySlot(url)
if (url.path == 'quit')
  puts "quit"
  exit()
elsif (url.path == 'cont')
  setHtml <<EOP
<html>
 <head>
  <title>test</title>
 </head>
 <body>
  <div>
This is a test. That works</br>
<h2><a id='click' href="quit" onclick="quit()">Quit</a></h2>
  </div>
 </body>
</html>
EOP
 end
  end
end

Qt::Application.new(ARGV) do
   A.new() do |view|
view.page.setLinkDelegationPolicy(Qt::WebPage::DelegateAllLinks)
view.setHtml <<EOP
<html>
 <head>
  <title>test</title>
 </head>
 <body>
  <div>
This is a test.</br>
<a id='click' href="quit" onclick="quit()">quit</a>
<a id='click' href="cont" onclick="quit()">Click on me!</a>
  </div>
 </body>
</html>
EOP
view.show
  end
  exec
end
</code>```

The only down side is that you will, in most cases, have to read the Qt C++ documentation and convert it into Ruby.  At least that is my experiance.

http://doc.qt.nokia.com/4.7-snapshot/qtwebkit.html

http://zetcode.com/gui/rubyqt/

Body:
Qt has a Webkit module.  You should be able to create a a UI using those to do what you want.

Here is an example of a dynamic page using QtRuby

require 'Qt4'
require 'qtwebkit'

class A < Qt::WebView
  slots 'mySlot(QUrl)'
  def initialize()
super()
connect(self, SIGNAL('linkClicked(QUrl)'), self, SLOT('mySlot(QUrl)'))
  end
  def mySlot(url)
if (url.path == 'quit')
  puts "quit"
  exit()
elsif (url.path == 'cont')
  setHtml <<EOP
<html>
 <head>
  <title>test</title>
 </head>
 <body>
  <div>
This is a test. That works</br>
<h2><a id='click' href="quit" onclick="quit()">Quit</a></h2>
  </div>
 </body>
</html>
EOP
 end
  end
end

Qt::Application.new(ARGV) do
   A.new() do |view|
view.page.setLinkDelegationPolicy(Qt::WebPage::DelegateAllLinks)
view.setHtml <<EOP
<html>
 <head>
  <title>test</title>
 </head>
 <body>
  <div>
This is a test.</br>
<a id='click' href="quit" onclick="quit()">quit</a>
<a id='click' href="cont" onclick="quit()">Click on me!</a>
  </div>
 </body>
</html>
EOP
view.show
  end
  exec
end

The only down side is that you will, in most cases, have to read the Qt C++ documentation and convert it into Ruby.  At least that is my experiance.

http://doc.qt.nokia.com/4.7-snapshot/qtwebkit.html

http://zetcode.com/gui/rubyqt/


问:
Web Developer or Software Engineer?
A question that I have been asking myself and really confused which path to take.

So I need your guys help as to the pros and cons of these 2 professions in today's world. I love web applications development as the Web is the best thing to happen in this age and nearly everyone gets by on the World Wide Web. And also tend to keep learning about new technologies and about web services.

On the other hand I like software engineering also for the desktop applications as I have had experience with development small scale software in VB.Net, Java, C++, etc.

Which path has more scope and better future? What's your view?

答:
Well, I personally would say that you should go for the web Developing fruit which lets you up to a new world of innovation and your innovative ideas would reach the world wide sites.

With the broad inclusion of Javascript, Ajax, Flash, ActionScript and many other options make your bain to create truely specified standard Sites.

Title: Web Developer or Software Engineer?


问:
What is the best way to handle references in a .NET application
Recently at work we ran into a problem where we tagged/branched a project and had some compiling issues because of dll/project references that was pointing to the old folder structure.

We created an 'external bin' folder for each of the projects and copied the referenced dll's to these folders. Is this the best way or is there a specific industry standard to handle this?

答: When using subversion for version control, you can utilize the "externals" property for this purpose. This allows you to keep a local copy of a shared DLL in a relative path nearby your current project. That makes it easy to reference that DLL by a relative file path which does not change, even when you change the main directory of your project to a different folder. Externals let you also define which specfic version or revision to include.</p>


问:
What is the relationship between OpenGL, GLX, DRI, and Mesa3D?
I am starting out doing some low-level 3D programming in Linux. I have a lot of experience using the higher level graphics API OpenInventor.

I know it is not strictly necessary to be aware of how all these things fit together but I'm just curious. I know OpenGL is just a standard for graphics applications. Mesa3D seems to be an open source implementation of this standard.

So where do GLX and DRI fit? Digging around on Wikipedia and all these websites, I've yet to find an explanation of exactly how it all goes together. Where does hardware acceleration happen? What do proprietary drivers have to do with this?

答:
OpenGL is platform agnostic; that means that the OpenGL API is platform independent.

The OpenGL states and buffers are collected by an abstract object, commonly called context.

The hosting platform is responsible to provide some API to create the OpenGL context for the underlying platform. On Windows there are the wgl* routines (Windows for GL), on Unix there are glX* routines (GL for X).

Indeed GLX is nothing but an API that allow application to create OpenGL context, in order to use OpenGL API.

Common WGL/GLX operations are  the creation of a window, the creation of an off-screen buffer, make OpenGL context current on a thread, swap draw buffers...

DRI instead is a kernel layer that allow direct communication with the graphic card, by-passing the XServer, indeed speeding up the application using OpenGL routines.


问:
Separation versus Segregation
The term "segregation" is used in the CQRS pattern.

What's the difference between segregation versus separation in this case?

答:
To try and answer your question, lets look at where the pattern came from.

Command Query Separation (CQS) where the querying will not change the state of the object (Only the commands would). The key point (in this context) is a class would consist of both Commands and Queries.

Command Query Responsibility Segregation (CQRS), holds the same principal logic (commands can alter the state and queries do not alter the state) and takes it one step further. Where the Commands are in different classes (even a different model) to the Queries.

As mentioned the Separation and Segregation are synonymous in the English language, however the patterns model their classes slightly differently to achieve this goal.

this is my understanding, and hopefully this may shed light on the context.

Title: Separation versus Segregation


答:
Thanks to ideas from previous answers, I'd like to propose the solution I have now though of; I hope this may invite one or two comments from the cyclopedical knowledge present here and help me to improve it.
Just for clarification: Although important issues, my question was not dealing with how to choose a Payment Service Provider (PSP), PCI DSS requirements or legal implications of anything, but just technical pitfalls one might stumble across when implementing a "direct" instead of a "redirect" model with any PSP.

Prerequisites

The customer is at the stage where he inputs credit card details into your form. I know what he owes and what amount and currency I want to charge to the credit card he submits.

Solution (?)

On submit of the form containing the Credit Card details, I will use Javascript to stop the default action on the submit button (which, if JS or AJAX weren't available, could go to an error page telling the user to get a more recent browser...)

The (repeated by a timer) AJAX request would call a status update script, that in itself triggers the actual processing in a seperate file; using "ignore_user_abort() should the client close the browser or something

so AJAX calls e.g. the method ->StatusUpdate() - if called for the first time, it would start the process and return "pleasewait", on subsequent calls it would evaluate a session variable or something to update the status

I would update the user's record in the database to set a "lockSession" flag to "locked" - should something happen before unlock, the user would be told on subsequent logins to contact the office to sort out any mess that may have happend...

insert a payment record into the DB with a "prepared" status

Submit the request to the PSP, using the order id of the prepared payment record. Depending on the PSP, the request can be submitted as a delayed transaction (meaning it won't be settled automatically)

update the prepared record with it's new status (if declined, unlock session and go back to the payment page; if successful, update with status "transmitted")

If it was successful, we would not have the auth reference and other important details from the PSP - so send "settle" request to the PSP for the obtained auth reference.

If successful, update the payment record to completed (or in my case, move and update it from PendingTransactions to PaymentTransactions)

Remove the "lock" flag from the user's record

Other considerations

Please understand the above as an invitation to share your knowledge and ideas - they're only ideas so far!

Logging

I would very much agree with nerdklers on the logging - I'm currently considering to use some form of file-based logging for every stage of the above process (and to keep logs for a few days even if complete and verified - who knows...)

Database transactions

I'm not sure I would agree with using database transactions. We're using MS SQL, and with default settings, any transaction would be rolled back on loss of connection. And when setting the transaction to not auto-commit or auto-rollback, one might end up with a few open DB transactions and some implications on record/table locking etc.
I think I'll prefer multiple updates in the process; should any of those fail (and the process consequently be terminated) the user would still be prevented from re-submitting a possibly completed (but not yet recorded) transaction until it has been resolved manually.

AJAX,  political

I'm not entirely certain whether we still need to consider browsers that won't support AJAX. I guess that's a "political" topic anyway. I think we could afford to take liberties in our business, others may possibly not.

AJAX, technical

I'm not so sure about my approach with calling a "StatusUpdate" method asynchronously yet, that will on first call attempt to trigger the actual process. But I shall make this a seperate question should I not find good examples - which I guess I might well find. Anyhow, if you know a best-practice please do let me (and others) know in your comment.

Final thoughts

It'd be nice if I had a thought even remotely approaching the term "final" - this if work in progress for me and I am much obliged for any feedback and further hints on how this could be improved.

Title: Integrating with a payment provider; Proper and robust OOP approach

Body:
History

We are currently using a so called redirect model for our online payments (where you send the payer to a payment gateway, where he inputs his payment details - the gateway will then return him to a success/failure callback page). That's easy and straight-forward, but unfortunately quite inconvenient and at times confusing for our customers (leaving the site, changing their credit card details with an additional login on another site etc).

Intention & Problem description

We are now intending to switch to an integrated approach using an exchange of XML requests and responses. My problem is on how to cater with all (or rather most) of the things that may happen during processing - bearing in mind that normally simplicity is robust whereas complexity is fragile.

Examples

User abort: The user inputs Credit Card details and hits submit. An XML message to the provider's gateway is sent and waiting for response. The user hits "stop" in his browser or closes the window.

ignore_user_abort() in PHP may be an option - but is that reliable?

might it be better to redirect the user to a "please wait"-page, that in turn opens an AJAX or other request to the actual processor that does not rely on the connection?

Database goes away

sounds over-complicated, but with e.g. a webserver in the States and a DB in the UK, it has happened and will happen again: User clicks together his order, payment request has been sent to the provider but the response cannot be stored in the database. What approach could I use, using PHP to sort of start an SQL like "Transaction" that only at the very end gets committed or rolled back, depending on the individual steps? Should then neither commit or roll back have happened, I could sort of "lock" the user to prevent him from paying again or to improperly account for payments - but how?

And what else do I need to consider technically? None of the integration examples of e.g. Worldpay, Realex or SagePay offer any insight, and either my search engine or my search terms weren't good enough to find somebody else's thoughts on this.

Thank you very much for any insight on how you would approach this!


问:
Data architecture for event log metrics?
My service has a large ongoing number of user events, and we would like to do things like "count occurrence of event type T since date D."

We are trying to make two basic decisions:

What to store?  Storing every event vs. only storing aggregates

(Event log style) log every event and count them later, vs.

(Time-series style) store a single aggregated "count of event E for date D" for every day

Where to store the data

In a relational database (particularly MySQL)

In a non-relational (NoSQL) database

In flat log files (collected centrally over the network via syslog-ng)

What is standard practice / where can I read more about comparing the different types of systems?

Additional details:

The total event stream is large, potentially hundreds of thousands of entries per day

But our current need is only to count certain types of events within it

We don't necessarily need real-time access to the raw data or aggregation results

IMHO, "log all events to files, crawl them at a later time to filter and aggregate the stream" is a pretty standard UNIX Way, but my Rails-y compatriots seem to think that nothing is real unless it's in MySQL.

答:
It always depends, I'll give you my advice to offer you a new perspective

What to store? Storing every event vs. only storing aggregates

(Event log style) log every event and count them later, vs.

If you plan to don't miss any detail, even though now they are not relevant, on my eyes that's the best approach, because sometimes, as the results comes, then you find some other events that for X or Y they were not relevant, or they didn't bring any extra information, but after some analysis, it simply does, and you need to also track that one, then because its recorded but not accounted it would take you some time before you can add it to the picture.

(Time-series style) store a single aggregated "count of event E for date D" for every day

If you want to implement and use it tomorrow, it can work, but then if you have a new requirements, or you find a correlation with another event that you omitted for any reason, then you need to add this new event and then wait some long time to have nice aggregation levels

Where to store the data

In a relational database (particularly MySQL)

The first option can be heavy for a DB if you go for recording all events, so MySQL I'm afraid can become too small, and if you want to go for RDBMS solutions you may think bigger, like PostgreSQL or proprietary like Oracle or DB2.

But for the aggregation would be a good choice, depending of the load generated you can aggregate in code and insert those aggregations in the DB.

In a non-relational (NoSQL) database

If you go for this solution, you need to see which approach you want to follow nice read on wikipedia may help you, I can't help you much on that topic because I simply don't have enough experience, I mostly use rdbms.

In flat log files (collected centrally over the network via syslog-ng)

I personally would discourage you to go for that option, If the file grows too much, it would be more difficult to parse, but still I don't know the main purpose, is to follow up on a system, or simply check a log file ...

Hope it helps!


答:
Any architecture decisión should be driven by business needs. In your case, you should have a more clear idea of what information do you want to obtain from your log system and in order to decide how to store, how often you will require this info and how much time you can wait to get the result. This is what drives the design of log collectors, event correlators and similar applications.

Rather than giving you my opinion, I suggest you look at some applications similar to what you try to develop. Some of them may be way more powerful that what you pretend to develop but it won't hurt if you look at the architecture and storage policies followed. On the professional side, you have SIEM applications like RSA and Arcsight and in the Open Source side you have initiatives like Kiwi or OSSIM (that has also a professional appliance based version).

Another thing to consider is that when you start using the results obtained by the tool, you will start receiving very likely many requests from your management for more information and more detailed one. So... use it carefully and plan with your view in the horizon. It may give you more work, but definitely you may get a lot of support and visibility (pressure comes in the package)....

Title: Data architecture for event log metrics?

Body:
My service has a large ongoing number of user events, and we would like to do things like "count occurrence of event type T since date D."

We are trying to make two basic decisions:

What to store?  Storing every event vs. only storing aggregates

(Event log style) log every event and count them later, vs.

(Time-series style) store a single aggregated "count of event E for date D" for every day

Where to store the data

In a relational database (particularly MySQL)

In a non-relational (NoSQL) database

In flat log files (collected centrally over the network via syslog-ng)

What is standard practice / where can I read more about comparing the different types of systems?

Additional details:

The total event stream is large, potentially hundreds of thousands of entries per day

But our current need is only to count certain types of events within it

We don't necessarily need real-time access to the raw data or aggregation results

IMHO, "log all events to files, crawl them at a later time to filter and aggregate the stream" is a pretty standard UNIX Way, but my Rails-y compatriots seem to think that nothing is real unless it's in MySQL.


答:
Its not really - Microsoft says the best way to handle references is to build your project in one huge solution. Yes, I know, they really do mean it too.

The patterns and practices team have put their best practices together with regard to TFS, but it applies to general builds. There are 3 types of solution setup, the "1 big solution", a partitioned approach which is a lot like how most people used to manage builds by building in turn and copying artifacts to a common directory (which si not helped by .NET not having a server-wide 'include' or 'library' path to reference), and a Multiple Solution setup which is a more complex version of the Partitioned one.

They say

```<code>In general you should:

    Use a single solution strategy unless the resulting solution is too large to load into Visual Studio.
    Use multiple solutions to create specific views on sub-systems of your application.
    Use multiple solutions to reduce the time it takes to load a solution and to reduce build time for developers.
</code>```

For TFS they recommend branching any external projects inside your project, rather than relying on the workspace mapping that is more akin to subversion's externals. Personally, I think their advice there is not best practice, but I suppose they are trying to minimise any build issues you'll get when using references.

I have had issues with .NET builds that try to shortcut the system by building only what's needed, a nightly build that does everything, and copies every new assembly to a directory was the best way for everyone to keep in sync - especially the testers. Note this really only applies to .NET apps, C++ ones tend to still work because they don't have versioned assemblies or similar aspects that can cause problems with calling components. This approach works well, but you can't always assume that partial builds are ok, vaping the whole thing and rebuild is safest.

Title: What is the best way to handle references in a .NET application

Body:
Recently at work we ran into a problem where we tagged/branched a project and had some compiling issues because of dll/project references that was pointing to the old folder structure.

We created an 'external bin' folder for each of the projects and copied the referenced dll's to these folders. Is this the best way or is there a specific industry standard to handle this?

Body:
Its not really - Microsoft says the best way to handle references is to build your project in one huge solution. Yes, I know, they really do mean it too.

The patterns and practices team have put their best practices together with regard to TFS, but it applies to general builds. There are 3 types of solution setup, the "1 big solution", a partitioned approach which is a lot like how most people used to manage builds by building in turn and copying artifacts to a common directory (which si not helped by .NET not having a server-wide 'include' or 'library' path to reference), and a Multiple Solution setup which is a more complex version of the Partitioned one.

They say

In general you should:

    Use a single solution strategy unless the resulting solution is too large to load into Visual Studio.
    Use multiple solutions to create specific views on sub-systems of your application.
    Use multiple solutions to reduce the time it takes to load a solution and to reduce build time for developers.

For TFS they recommend branching any external projects inside your project, rather than relying on the workspace mapping that is more akin to subversion's externals. Personally, I think their advice there is not best practice, but I suppose they are trying to minimise any build issues you'll get when using references.

I have had issues with .NET builds that try to shortcut the system by building only what's needed, a nightly build that does everything, and copies every new assembly to a directory was the best way for everyone to keep in sync - especially the testers. Note this really only applies to .NET apps, C++ ones tend to still work because they don't have versioned assemblies or similar aspects that can cause problems with calling components. This approach works well, but you can't always assume that partial builds are ok, vaping the whole thing and rebuild is safest.


问:
Should I be using a JavaScript SPA designed when security is important
I asked something kind of similar on stackoverflow with a particular piece of code however I want to try to ask this in a broader sense.

So I have this web application that I have started to write in backbone using a Single Page Architecture (SPA) however I am starting to second guess myself because of security.  Now we are not storing and sending credit card information or anything like that through this web application but we are storing sensitive information that people are uploading to us and will have the ability to re-download too.

The obviously security concern that I have with JavaScript is that you can't trust anything that comes from JavaScript however in a Backbone SPA application, everything is being sent through JavaScript. There are two security features that I will have to build in JavaScript; permissions and authentication.

The authentication piece is just me override the Backbone.Router.prototype.navigate method to check the fragment it is trying to load and if the JavaScript application.session.loggedIn is not set to true (and they are not viewing a none authenticated page), they are redirected to the login page automatically.  The user could easily modify application.session.loggedIn to equal true (or modify Backbone.Router.prototype.navigate method) but then they would also have to not so easily dynamically embedded a link into the page (or modify a current one) that has the proper classes, data-* attributes, and href values to then load a page that should only be loaded when they user has logged in (and has the permissions).

So I have an acl object that deals with the permissions stuff.  All someone would have to do to view pages or parts of pages they should not be able to is to call acl.addPermission(resource, permission) with the proper permissions or modify the acl.hasPermission() to always return true and then navigate away and then back to the page.

Now certain things is EMCAScript 5 like Object.seal() or Object.freeze() would help with some of this however we have to support IE 8 which does not support those pieces of functionality.

Now the REST API also performs security checks on every request so technically even if they are able to see parts of the interface that they should not be able to, they still should not be able to actually affect any data.

The main benefits for me in developing a JavaScript SPA application is that the application is a lot more responsive since it is only transferring the minimum amount of JSON data for the requested action and performing the minimum amount of work too.  There are also other things that I think are beneficial like you are going to have to develop an API for the data (which is good if you want expand your application to different platforms/technologies) or their is more of a separation between front-end and back-end however if security is a concern, it is really wise to go down the road of a JavaScript SPA application for the front-end?

答:
I wouldnt rely on the client side javascript to tell you if the user is logged in.  That can easily be changed.

The couple of times I've made 'single page' type web interfaces, I did it with two 'pages'.  The first page encountered was a login page.  When submitted, that allowed for the creation of a traditional web session on the server, and then returned back the 'application' page, which then immediately loaded everything by ajax requests.  For all subsequent ajax calls the cookie was sent with the request, so authentication worked the same way as it does in traditional applications.  So there's nothing particular you have to do differently in your javascript to support this.  Every server side response must, of course, validate the session.

I say two 'pages', but they were really the same 'index.php' - it just returned either a login page or the main application page depending on whether a valid 'login' was set in the server-side session.  In your case, you'd just have node return two different page templates.


问:
Making two images move at different speeds in Java?
I am creating a basic game of space invaders. I am using a thread to animate the game and was wondering, how do I get the aliens the speed up going left and right without changing the speed of the ship you control below them?

What is the easiest method? I am quite new to Java 2d and have only created two other more basic games.

答: Your frame rate shouldn't be tied to the content of the frame, and the trajectory of each object over time should be independent.  When preparing a frame representing time "x", each moving object has it's own position.</p>


答:
The basic idea when doing this is to give each object a Speed property, and then have a timer variable.

For each frame, when rendering:

Calculate the length of time since you started rendering the last frame, in milliseconds.  Call this Delta.

Update the timer with the current timestamp.

For each object, use Delta and the object's Speed property to determine its new position.

Render all objects at the correct position.

Note that in this model movement speed is tied to time elapsed, and not to the rendering itself.  This way, if your frame rate goes up or down for whatever reason, things still move at a consistent rate.

Title: Making two images move at different speeds in Java?

Body:
I am creating a basic game of space invaders. I am using a thread to animate the game and was wondering, how do I get the aliens the speed up going left and right without changing the speed of the ship you control below them?

What is the easiest method? I am quite new to Java 2d and have only created two other more basic games.


答:
I give you some resources that will be fruitful to you:

Space Invaders - A Java 2D Tutorial

Java 2D Games Tutorial

Some Java 2D/3D Tutorials

2d simplistic space invaders game in Java

Space Invaders - 2D Rendering in Java

Creating a Java platform game as easily as possible


问:
How can I send audio input as chunked HTTP?
I am trying to create an interface with an external server, and don't know where to start.   I would need to take audio as input to my computer, and send it to the remote server as a chunked HTTP request.  The API that I'm trying to connect to is described here p1-5

http://dragonmobile.nuancemobiledeveloper.com/public/Help/HttpInterface/HTTP_Services_for_NDEV_v1.2_Silver_Version.pdf

I have never worked with audio programmatically, so don't know what would be the most straightforward way to go about this?   Are there solutions that exist out there that already do this?

I've come across references to Shoutcast, VLC, Icecast, FFMPeg, Darkice, but I don't know if those are appropriate for what I'm trying to accomplish or not.

答: It looks like you need to encode your audio as 8KHz 16-bit PCM, then split it into 260ms chunks and send those one at a time to the service.  The actual encoding method for the data isn't specified, I'd start with converting the samples to network byte order then stick the octets into the request as UTF-8 and see if that works.</p>


问:
Transaction classification. Artificial intelligence
For a project, I have to classify a list of banking transactions based on their description.

Supose I have 2 categories: health and entertainment. Initially, the transactions will have basic information: date and time, ammount and a description given by the user. For example:

```<code>Transaction 1: 09/17/2012 12:23:02 pm - 45.32$ - "medicine payments"
Transaction 2: 09/18/2012 1:56:54 pm - 8.99$ - "movie ticket"
Transaction 3: 09/18/2012 7:46:37 pm - 299.45$ - "dentist appointment"
Transaction 4: 09/19/2012 6:50:17 am - 45.32$ - "videogame shopping"
</code>```

The idea is to use that description to classify the transaction. 1 and 3 would go to "health" category while 2 and 4 would go to "entertainment".

I want to use the google prediction API to do this. In reality, I have 7 different categories, and for each one, a lot of key words related to that category. I would use some for training and some for testing.

Is this even possible? I mean, to determine the category given a few words? Plus, the number of words is not necesarally the same on every transaction.

Thanks for any help or guidance! Very appreciated

Possible solution: https://developers.google.com/prediction/docs/hello_world?hl=es#theproblem

答:
I have 7 different categories, and for each one, a lot of key words related to that category. I would use some for training and some for testing.

Sounds like a simple Bayesian classification should work well. I'm sure there's libraries which implement that for all major programming languages.


答:
In C++11 you can use a constexpr constructor like this:

```<code>class Info {
    const int a;
    const int b;
    const char *c;
public:
    constexpr Info(const int, const int, const char *);
    const int get_a() { return a; }
    const int get_b() { return b; }
    const char *get_c() const { return c; }
};

constexpr Info::Info(const int a, const int b, const char *c) : a(a), b(b), c(c) {}

constexpr Info list[] = {
    Info(1, 2, "a"),
    Info(3, 4, "b"),
};
</code>```

GCC 4.7.1 in C++0x mode supports constexpr constructors at compile time, and the above code works as desired, with no calls to the Info constructor in the generated code.

Note that the compiler is not required to do full construction at compile time - in principle it could defer the construction to runtime.

Title: Can I get a C++ Compiler to instantiate objects at compile time

Body:
I am writing some code that has a very large number of reasonably simple objects and I would like them the be created at compile time.  I would think that a compiler would be able to do this, but I have not been able to figure out how.

In C I could do the the following:

```<code>#include <stdio.h>

typedef struct data_s {
    int a;
    int b;
    char *c;
} info;

info list[] = {
    1, 2, "a",
    3, 4, "b",
};

main()
{
   int i;
   for (i = 0; i < sizeof(list)/sizeof(*list); i++) {
     printf("%d %s\n", i, list[i].c);
   }
}
</code>```

Using #C++* each object has it constructor called rather than just being layed out in memory.

```<code>#include <iostream>
using std::cout;
using std::endl;

class Info {
    const int a;
    const int b;
    const char *c;
public:
    Info(const int, const int, const char *);
    const int get_a() { return a; };
    const int get_b() { return b; };
    const char *get_c() const { return c; };
};

Info::Info(const int a, const int b, const char *c) : a(a), b(b), c(c) {};

Info list[] = {
    Info(1, 2, "a"),
    Info(3, 4, "b"),
};

main()
{
    for (int i = 0; i < sizeof(list)/sizeof(*list); i++) {
        cout << i << " " << list[i].get_c() << endl;
    }
}
</code>```

I just don't see what information is not available for the compiler to completely  instantiate these objects at compile time, so I assume I am missing something.

Body:
In C++11 you can use a constexpr constructor like this:

class Info {
    const int a;
    const int b;
    const char *c;
public:
    constexpr Info(const int, const int, const char *);
    const int get_a() { return a; }
    const int get_b() { return b; }
    const char *get_c() const { return c; }
};

constexpr Info::Info(const int a, const int b, const char *c) : a(a), b(b), c(c) {}

constexpr Info list[] = {
    Info(1, 2, "a"),
    Info(3, 4, "b"),
};

GCC 4.7.1 in C++0x mode supports constexpr constructors at compile time, and the above code works as desired, with no calls to the Info constructor in the generated code.

Note that the compiler is not required to do full construction at compile time - in principle it could defer the construction to runtime.


问:
What encryption algorithm/package should I use in a betting game?
I have a betting type site where I publish a number (between 0-100) that is encrypted. Then after a period of time, I would review what the number is and prove it with a key to decrypt the encrypted number to prove that I'm not cheating. I also want it to be easily verifiable by an average user.

What encryption algorithm/technique/package should I use?

I'm no expert on cryptography. There seems to be so many options out there and I'm not sure what to use.

python friendly is a plus.

答:
Conceivably this is a better question for the Stack Exchange Security site, but...

The fact that you have encrypted the number doesn't prove you aren't cheating.  It just proves you encrypted the number.  The question you are asking is called, probably among other things, Mental Poker.  The idea is that every party needs to perform some random step and encrypt it.

I included the reference because it can get you started, but for a single random number one might do:

Alice picks a random number A from 0 to 99 and encrypts it.

Bob does the same for number B.

The "real" random number is (A+B) mod 100.  This can be verified when both parties reveal their private keys.

You can use any single-key encryption for this simple scheme.  You will have to generate lots of keys so they must be created using cryptographically strong key generation.

This scheme isn't computationally cheap.

You can probably do better for a specific algorithm, but hopefully this answer can get you started.  I don't think any secure scheme will be all that cheap, but it isn't clear how many of these numbers you need.


问:
What problems can arise from emulating concepts from another languages?
I've read many times on the web that if your language doesn't support some concept, for example, object orientation, or maybe function calls, and it's considered a good practice in this other context, you should do it.

The only problem I can see now is that other programmers may find your code too different than the usual, making it hard for them to program. What other problems do you think may arise from this?

答:
One of the problems is that you may find yourself writing lots of code to express something in a way you will do in another language, while there is a more straightforward way in the language you use.

For example, in an answer on Stack Overflow, I've explained how code contracts, concept used in .NET Framework, can be partially emulated in PHP which doesn't support them. I ended up writing lots of code for nothing, since the same thing was doable with simple arrays.

More generally, each language has its own culture, its own best practices, its own style.

If I start writing C# code like it was C, it would be ugly.

If I apprehend Haskell as a Java developer who was forced to use Haskell, but don't want to understand its strengths and just want to clone the concepts of Java, the code I would write will suffer.

etc.

There is nothing wrong trying to enhance the language (for example enhance C# by introducing units of measure like in F#), but if you are doing it too much, you should maybe choose a different language which actually fits your needs.


问:
Use switch statements for application flow?
I generally use switch statements to simplify a block of multiple if statements - for example - returning a feedback string to a user based on a multiple choice input.

I also tend to construct classes so that there is one "management" method, to avoid sequential steps or chained method invocation within other methods of the class. I've found this helps to keep methods flexible and focussed - i.e.

```<code>class MyClass{

    // this method does nothing more than invoke the relevant method
    // depending on the status following the previous. It's entire purpose
    // is to control application flow
    public function manageFlow($input){
        $status = $this->stepOne($input);
        if($status == false){
            //exit routine
        }

        $status = $this->stepTwo($input);
        if($status == false){
            //exit routine
       }
    }

    // this method has several sequential steps implemented direcly within it,
    // for example to a user logging in
    // it makes it impossible to re-use any of the intermediary steps
    public function tangledFlow($input){
         if($input == 'something){
         //100 lines of code
         }
         //then handing on to the next bit
         if($this->User->Authenticated){
         //another 100 lines...
         }
    }
}
</code>```

Then it occurred to me that I could use a switch statement to control this kind of sequential execution - so my question is: has anyone used a switch statement for this kind of flow control?

答: What you're describing is a state machine, and yes, many people do use switch statements to implement those.  They're usually cleaner, but it can be more difficult to follow the logic flow.

ContentLicense: CC BY-SA 2.5


答:
Тhe drop in readability is enough of a problem in itself: it drastically decreases the pool of people who could potentially maintain your project without an extensive training from you.

In addition,

Implementing the foreign paradigm may cost more than the potential savings from its use

Your adaptation of the foreign functionality may be buggy, increasing the costs of maintenance

Your adaptation of the foreign functionality may push your technology stack to the limits beyond these required by your native implementation.

Title: What problems can arise from emulating concepts from another languages?

Body:
I've read many times on the web that if your language doesn't support some concept, for example, object orientation, or maybe function calls, and it's considered a good practice in this other context, you should do it.

The only problem I can see now is that other programmers may find your code too different than the usual, making it hard for them to program. What other problems do you think may arise from this?


答:
What problems can arise from emulating concepts from another languages?

Leaky abstractions.


答:
It can be prohibitively difficult.  Imagine trying to implement LINQ from C# into your Java application.  Or how about just adding lexical closures to a language?  You would pretty much have to write a new compiler, which pretty much gives you a new language.

Or,for cases where you don't have to implement your own language, just imagine trying to implement collection methods using higher order functions (like map) in a language that doesn't have code blocks or lambda functions or closures or functions as first class objects.  Every higher order function has to be declared as an interface and implemented explicitly, and all state that would have been captured in a closure must be explicitly stored in the implementing class.  It's so much extra typing, and so much harder to read, that it often isn't worth it.


问:
How should I create a mutable, varied jtree with arbitrary/generic category nodes?
Please note: I don't want coding help here, I'm on Programmers for a reason. I want to improve my program planning/writing skills not (just) my understanding of Java.

I'm trying to figure out how to make a tree which has an arbitrary category system, based on the skills listed for this LARP game here. My previous attempt had a bool for whether a skill was also a category. Trying to code around that was messy. Drawing out my tree I noticed that only my 'leaves' were skills and I'd labeled the others as categories.

What I'm after is a way to make a tree which attempts to separate Model and View, and allow adding an arbitary type of child node (with a separate way of being edited/rendered) to an arbitrary parent.

N.B Everything here is bought as a skill, even where it seems like a property. The End-Users will see this as buying skills (which they do on paper atm) so should be presented as such, all on the same page.

Explanation of tree: The Tree is 'born' with a set of hard coded highest level categories (Weapons, Physical and Mental, Medical and more etc.). From this the user needs to be able to add a skill. Ultimately they want to add the 'One-handed Sword Specialisation' skill (not item) for instance. To do so you'd ideally click 'add' with Weapons selected and then select One-handed from a combobox node that appears on that child, then click add again and enter a name in a text field on that child node that appears. Then click add again to add/specify a 'level' or 'tier' for that leaf; first proficiency, then specialisation (for example).

Of course if you want to buy a different skill it's a completely different route to the leaf. You might not need a combo box at the same level down the tree as you did with the weapon example, and need some other logic behind it too. This is what I'm having trouble getting my head around let alone programming in; how to make a set of classes and not specify what order to attach them together in, but still have them all fit.

What is a good system for describing this sort of tree in code? All the other JTree examples I've seen have some predictable pattern, and mine doesn't. I don't want to have to code this all in 'literals', with long lists of what type (combo-box, text field etc) of children node should be allowed on what parent. Should I be using abstract classes? Interfaces?

How can I make this sort of cluster of objects extensible when I add in other skills not listed above that behave differently?

If there is not a good system to use, is there a good process for working out how to do this sort of thing?

The gears in my head are turning:

I always need to:

Check the parent

Provide options based on the parent

I'm begining to think becasue of this commonality I need some sort of abstract/interface skill class that defines/outlines common methods for skill and category. I can (hopefully) put rules and options in a database and read to-from there. The question is I think now, between an abstract or interface method and how to bes implement that.

答:
I'm going to focus on the object model.

I think for the flexibility you want, you probably want to separate your classes into a knowledge (perhaps "definition" is a better word in this case) layer and a transaction layer.  By "layer" I really just mean separating them logically in your head.  The knowledge layer contains your definition of how to lay out the tree, and data in it comes from a game designer and the data layer stores particular choices for a particular character.

Your knowledge level will be at least slightly messy, because you are trying to make a cool game rather than a mathematically clean model.

Trying to organize what you have so far, I think you have a SkillDefinition class has a Parent property of type SkillDefinition.  You also have subclasses of SkillDefinition (which may become entries in a DEF_SkillType table in the database) to cover a few cases.

"Weapons","Physical and Mental", and "Medical" seem have nothing but a title (and child skills).

"One Handed", "Strength", and "Bind Wounds" seem to have an associated combo box (which means something like a DEF_SkillChoice table on the database with a foreign key to DEF_Skill). Sword and Bow seem to be a user defined string (so no associated table at the knowledge level, but the data will be stored at the transaction layer).

"Life" seems to have an integer associated with it.  It might not be able to share this class with any future characteristics that use an integer, because there is implied behavior on how the integer is incremented.  In any case, it currently does need its own class.

"Sword", "Bow", "Strength", and "Bind Wounds" all seem to have associated levels of progressive skill below them in the tree.  In the case of "Sword" and "Bow", those levels are really associated with their parent skill.  I think you need a ProgressiveSkillDefinition class with an ordered collection of legal values (DEF_SkillLevel table with foreign key to DEF_Skill.  At the knowledge level it isn't fully clear what rules you are modeling.  If "proficiency" and "specialization" are always available for all weapons, you might have a DEF_SkillLevel table with the "proficiency" and "specialization" records having foreign keys to the "Weapons" record.  You could also have a DEF_SkillLevelSet table with DEF_SkillLevel records pointing to that, and "reverse" the foreign key from DEF_SkillLevel to SkillDefinition by replacing it with a foreign key from SkillDefinition to DEF_SkillLevelSet, but I wouldn't do that unless having many "proficiency" and "specialization" records was becoming a pain (which it won't if they only apply to "Weapon" anyway).

This covers what you have know at a knowledge level.  The transaction level (perhaps "character level" would be a better name?) just points to the appropriate knowledge level.  So, in your example, you would have a Character object with a Skills object that has a collection of skills - just the ones he actually has.

So, the character would have a "Proficiency" skill whose parent is the "sword" skill and whose type is  Skill_Level.  In the database the TRANS_SkillDefinition record has a foreign key to the transactional "sword" skill record and the knowledge level DEF_SkillLevel record with the name "Proficiency".

The proficiency skill would have a parent object of the "sword" skill, of type Skill_UserNamed.  In the database this would not have a foreign key to the knowledge level, because there is nothing special defined for "sword" (it's the user's name).  However it also has a foreign key to the parent transactional record, so more information is available through it.

The "sword" skill object has a parent object of "one-handed", because the user chose to put "sword" in the "one-handed" category.  This is an object of type SkillCategory.  In the database it has a foreign key to the DEF_SkillChoice table for the record "one-handed", and no transactional parent because all additional data for this skill is stored at the knowledge level.

In constructing the initial tree for a new character, only the knowledge level needs to be queried.  To populate the choices made for a character requires the transactional level.

You will need code to translate the object model into a tree, and back.  It should be clear, I hope, what you need to do - each type at the knowledge layer will have an associated set of controls on the tree, that gets data appropriate for that type.

Later you may want classes for each choice in the SkillCategory records, (if "Specialization" has behavior associated with it, the code has to go somewhere), but you don't need that yet for this tree, and this design will be compatible with that.  You will just have to have a factory that uses the knowledge level information to build the right object.


问:
C# Role Provider for multiple applications
I'm making a custom RoleProvider that I would like to use across multiple applications in the same application pool. For the administration of roles (create new role, add users to role, etc..) I would like to create a master application that I could login to and set the roles for each additional application. So for example, I might have AppA and AppB in my organization, and I need to make an application called AppRoleManager that can set roles for AppA and AppB. I am having troubles implementing my custom RoleProvider because it uses an initialize method that gets the application name from the config file, but I need the application name to be a variable (i.e. "AppA" or "AppB") and passed as a parameter. I thought about just implementing the required methods, and then also having additional methods that pass application name as a parameter, but that seems clunky. i.e.

```<code>public override CreateRole(string roleName)
{
  //uses the ApplicationName property of this, which is set in web.config
  //creates role in db
}
public CreateRole(string ApplicationName, string roleName)
{
  //creates role in db with specified params.
}
</code>```

Also, I would prefer if people were prevented from calling CreateRole(string roleName) because the current instance of the class might have a different applicationName value than intended (what should i do here? throw NotImplementedException?).

I tried just writing the class without inheriting RoleProvider. But it is required by the framework.

Any general ideas on how to structure this project?

I was thinking make a wrapper class that uses the role provider, and explicitly sets the application name before (and after) and calls to the provider something like this:

```<code>static class RoleProviderWrapper
{
  public static CreateRole(string pApplicationName, string pRoleName)
  {
    Roles.Provider.ApplicationName = pApplicationName;
    Roles.Provider.CreateRole(pRoleName);
    Roles.Provider.ApplicationName = "Generic";
  }
}
</code>```

is this my best-bet?

答:
If you ran the aspnet_regsql.exe that should give you a great start and you wont need to re-invent the wheel (at least to get started). It implements the default Membership provider and gives you a lot of "off the shelf" functionality, which is what you're describing.. user login, remember password, attribute driven authentication (for MVC), directory level permissioning, and configuration based login redirects, session timeouts etc..

The aspnet_regsql tool gives you an empty database schema and makes it super easy to tie the default membership behavior into your own app including; Role based folder access, multiple applications with single sign on support, and some other membership / profile type tables (i generally dont use them much)).

You can also manage users / roles from Visual Studio using the website configuration tools from the web based management website.. and this is all built in and available without any additional coding / plug-ins.. i highly recommend it for new apps since it gives you so much in so little time and lets you focus on the fun part (the app)..

Also, you can carve down what's generated from there, or use it as an example. I usually just tie in their User_ID into the user of my schema and put a trigger or "on user created" event to sync the GUID's. That way i can get a user login, retreive password, and remember me up and running in about 10 minutes (it also handles situations where cookies aren't enabled).. and if there is ever a need to implement a custom provider, you can circle back, but at least the underlying functionality doesnt stop the app development from moving forward.

some info about aspnet_regsql.exe from MS:

http://msdn.microsoft.com/en-us/library/ms229862(v=vs.100).aspx

Here's a much better walkthrough:

http://weblogs.asp.net/sreejukg/archive/2011/06/16/usage-of-aspnet-regsql-exe-in-asp-net-4.aspx


答:
You can use Clustering and Natural Language processing.

Coursera have excellent courses on this subjects:

https://www.coursera.org/course/nlp

https://www.coursera.org/course/compdata

https://www.coursera.org/course/ml

Title: Transaction classification. Artificial intelligence

Body:
For a project, I have to classify a list of banking transactions based on their description.

Supose I have 2 categories: health and entertainment. Initially, the transactions will have basic information: date and time, ammount and a description given by the user. For example:

```<code>Transaction 1: 09/17/2012 12:23:02 pm - 45.32$ - "medicine payments"
Transaction 2: 09/18/2012 1:56:54 pm - 8.99$ - "movie ticket"
Transaction 3: 09/18/2012 7:46:37 pm - 299.45$ - "dentist appointment"
Transaction 4: 09/19/2012 6:50:17 am - 45.32$ - "videogame shopping"
</code>```

The idea is to use that description to classify the transaction. 1 and 3 would go to "health" category while 2 and 4 would go to "entertainment".

I want to use the google prediction API to do this. In reality, I have 7 different categories, and for each one, a lot of key words related to that category. I would use some for training and some for testing.

Is this even possible? I mean, to determine the category given a few words? Plus, the number of words is not necesarally the same on every transaction.

Thanks for any help or guidance! Very appreciated

Possible solution: https://developers.google.com/prediction/docs/hello_world?hl=es#theproblem


答:
It's not as good idea as it appears on paper.

Example 1: If you're old enough, you may remember the days when C was the new kid in town. Pascal and Ada programmers didn't like C's terse open and close braces. They #defined begin and end to open brace and close brace, and voila! CAda! The unfortunate result was ugly from the perspective of either Ada or C.

Example 2, personal: One of the things I really liked about the Common Lisp Object System is it's before, after, and around methods. They can come so in very handy in multiple places. So I emulated this concept in C++ in a few select places. The only way to emulate these constructs in C++ is to require the developer of a derived class to call the parent class' method of the same name at the right place in the code. This put a requirement on developers who derived from my classes that was a bit foreign to C++ programming, and perhaps against the grain of C++ programming . No matter how well documented this requirement was, people just didn't follow the guidelines because it didn't quite fit the C++ paradigm.


问:
A good interpreted language for a small embedded project
I have an mbed microcontroller which has a small ARM Cortex M3 on it. Basically, my effective resources for the project are ~25 KB of RAM and ~400 KB of Flash. For I/O I'll have a PS/2 keyboard, a VGA framebuffer (with character output), and an SD card for saving/loading programs (up to a couple of MB maybe).

I ask because I'm trying to figure out what programming language to implement on the thing. I'm looking for an interpreted language that's easy for me to implement and won't break the bank on my resources. I also intend for this to be at least possible to write on the device itself, though the editor can be interpreted (yay, bootstrapping).

Anyway, I've looked at a few simple languages. Some nice candidates:

Forth

BASIC

Scheme?

Has anyone done something like this or know of any languages that can fit this bill or have comments about my three candidates so far?

答:
I remember reading some time ago about Tcl/Tk and its use in routers.

Excerpt from the "Embedded Development" paragraph found at http://www.tcl.tk/about/uses.html:

Because Tcl is a very compact language, and is easily integrated with
  special hardware, it is a popular choice for embedded development.
  You'll find Tcl hidden away on many devices, including many networking
  products from Cisco and others, and set-top boxes including Tivo.
  Embedding Tcl within other software projects is of course also hugely
  popular, and has become the dominant control language in some
  industries, such as in electronic design automation (EDA) and
  computer-aided design (CAD) applications.


答:
I'm going to make the case that Lua is by far your best bet. You can compile Lua anywhere that C can run and it's one of the lightest scripting languages out there. It's massively flexible as a language and the skills are quite transferable as well. There's even a specifically embedded version of Lua.

Addendum: It is apparently possible to get the memory footprint down to just over 25K.

Addendum 2 - Things get nutty: There is an option brought up by this SO question. Squirrel is a language that I've heard of but never used. It's apparently even smaller than Lua due to use of reference counting.

Title: A good interpreted language for a small embedded project

Body:
I have an mbed microcontroller which has a small ARM Cortex M3 on it. Basically, my effective resources for the project are ~25 KB of RAM and ~400 KB of Flash. For I/O I'll have a PS/2 keyboard, a VGA framebuffer (with character output), and an SD card for saving/loading programs (up to a couple of MB maybe).

I ask because I'm trying to figure out what programming language to implement on the thing. I'm looking for an interpreted language that's easy for me to implement and won't break the bank on my resources. I also intend for this to be at least possible to write on the device itself, though the editor can be interpreted (yay, bootstrapping).

Anyway, I've looked at a few simple languages. Some nice candidates:

Forth

BASIC

Scheme?

Has anyone done something like this or know of any languages that can fit this bill or have comments about my three candidates so far?


问:
Reasons behind polymorphism related behaviour in java
I read this code somewhere

```<code>class Foo {
    public int a;
    public Foo() {
        a = 3;
    }
    public void addFive() {
        a += 5;
    }
    public int getA() {
        System.out.println("we are here in base class!");
        return  a;
    }
}

public class Polymorphism extends Foo{
   public int a;
   public Poylmorphism() {
       a = 5;
   }
   public void addFive() {
       System.out.println("we are here !" + a);
       a += 5;
   }

   public int getA() {
        System.out.println("we are here in sub class!");
        return  a;
    }

    public static void main(String [] main) {
        Foo f = new Polymorphism();
        f.addFive();
        System.out.println(f.getA()); // SOP 1
        System.out.println(f.a);      // SOP 2
    }
}
</code>```

For SOP1 we get answer 10 and for SOP2 we get answer 3. Reason for this is that you can't override variables whereas you can do so for methods. This happens because type of the reference variable is checked when a variable is accessed and type of the object is checked when a method is accessed. But I am wondering, just why is it that way? Can anyone explain me what is the reason for this behaviour

答:
This happens because type of the reference variable is checked when a variable is accessed and type of the object is checked when a method is accessed. But I am wondering, just why is it that way? Can anyone explain me what is the reason for this behaviour

It is not a type issue, it is a binding issue.

The f.a expression binds statically to the field according to the declared type of the variable f because fields are cannot be overridden.  And the reason that they cannot be overridden is that that could break substitutability (for non-private fields) and break methods declared in the supertype that use the field.

The f.getA() call binds dynamically to the method in the actual object in order to implement dynamic polymorphism, and in order to prevent callers from breaking abstraction by mistakenly calling a method that had been overridden.

In short, if the binding method was different in either case, the net result would be a less expressive language with problems maintaining abstraction boundaries.

Most, if not all, statically typed OO languages work this way.  (If anyone knows of counter examples that are also statically typed, please comment.)


问:
Is there a standard for machine-readable descriptions of RESTful services?
I've interacted with a few RESTful APIs that provided excellent documentation for humans and descriptive URIs, but none of them seem to return machine-readable descriptions of themselves.

It's not too tough to write methods of my own that assemble the right paths, and many language-specific API libraries are already just wrappers around RESTful requests. But the next level of abstraction seems really useful: a library that could read in an API's own machine readable documentation and generate the wrappers automatically, perhaps with a call to some standard URI like base_url + '/documentation'

Are there any standards for machine-readable API documentation? Am I doing REST wrong? I am a relatively new programmer, but this seems like a good idea.

答:
Yes, there are multiple ways that you may use.

One of them is to generate your client code, tests and documentation using a set of tools supporting WADL. Some examples can be found in this blog post.

You may also find it better to use WADL, rather than WSDL 2.0 because it is less verbose and way simpler (IMHO). In fact, by using WADL you describe exactly what the user sees on the documentation page, just using WADL XML syntax. And it is also one of thereasons why it's so easy to write XSLT-based documentation generators for WADL.


问:
Fast programmatic compare of "timetable" data
Consider train timetable data, where each service (or "run") has a data structure as such:

public class TimeTable
{
    public int Id {get;set;}
    public List<Run> Runs {get;set;}
}

public class Run
{
    public List<Stop> Stops {get;set;}
    public int RunId {get;set;}
}

public class Stop
{
    public int StationId {get;set;}
    public TimeSpan? StopTime {get;set;}
    public bool IsStop {get;set;}
}
```

We have a list of runs that operate against a particular line (the TimeTable class).

Further, whilst we have a set collection of stations that are on a line, not all runs stop at all stations (that is, IsStop would be false, and StopTime would be null).

Now, imagine that we have received the initial timetable, processed it, and loaded it into the above data structure.  Once the initial load is complete, it is persisted into a database - the data structure is used only to load the timetable from its source and to persist it to the database.

We are now receiving an updated timetable.

The updated timetable may or may not have any changes to it - we don't know and are not told whether any changes are present.

What I would like to do is perform a compare for each run in an efficient manner.  I don't want to simply replace each run.  Instead, I want to have a background task that runs periodically that downloads the updated timetable dataset, and then compares it to the current timetable.  If differences are found, some action (not relevant to the question) will take place.

I was initially thinking of some sort of checksum process, where I could, for example, load both runs (that is, the one from the new timetable received and the one that has been persisted to the database) into the data structure and then add up all the hour components of the StopTime, and all the minute components of the StopTime and compare the results (i.e. both the sum of Hours and sum of Minutes would be the same, and differences introduced if a stop time is changed, a stop deleted or a new stop added).

Would that be a valid way to check for differences, or is there a better way to approach this problem?  I can see a problem that, for example, one stop is changed to be 2 minutes earlier, and another changed to be 2 minutes later would have a net zero change.

Or am I over thinking this, and  would it just be simpler to brute check all stops to ensure that

The updated run stops at the same stations; and

Each stop is at the same time

答:
am I over thinking this, and would it just be simpler to brute check all stops...

I think you are over thinking this. A check would run very quickly anyway. Even if there is a better way, you will spend so much time for a trivial benefit for the end user. This is especially true if the compare process runs on batch cycle.

You could also write the information to a sequential file (you will need a new structure) then create a hashed value based on all values, but this is kind of complex and you have to choose a hashing algorithm that generates unique keys.

Alternatively, you could use the same linear structure and run a compare utility to flag the difference(s) (if any). If no difference(s) found, you don't load the new schedule, otherwise, perform the update using the deltas.

I don't think there would be a simple way to compare the 2 sets without brute force.

Always try to Keep it simple ;)


问:
How should an API use http basic authentication
When an API requires that a client authenticates to it, i've seen two different scenarios used and I am wondering which case I should use for my situation.

Example 1. An API is offered by a company to allow third parties to authenticate with a token and secret using HTTP Basic.

Example 2. An API accepts a username and password via HTTP Basic to authenticate an end user.  Generally they get a token back for future requests.

My Setup: I will have an JSON API that I use as my backend for a mobile and web app.  It seems like good practice for both the mobile and web app to send along a token and secret so only these two apps can access the API blocking any other third party.

But the mobile and web app allow users to login and submit posts, view their data, etc.  So I would want them to login via HTTP Basic as well on each request.

Do I somehow use a combination of both these methods or only send the end user credentials (username and token) on each request?  If I only send the end user credentials, do I store them in a cookie on the client?

答:
Can OAuth / OpenID work, along with token / secret?

I recently contemplated the following scenario:

Web Application Front End

Underlying REST API

Mobile Device Applications, accessing REST API

As a simple test, I was able to:

Authenticate users via the Web Application using OAuth

The REST API authorized via OAuth, resulting in a secret being generated and passed back to the client

The Mobile Device would then authenticate via OAuth, and then be authorized by the REST API via the secret

This would allow the Mobile Device Application to authenticate with the same credentials as via the Web Front End (the same account) and also be able to authorize access to the API.


答:
Regarding embeddable scripting languages, the 2 I'm familiar with are LUA  and PAWN .

I think there are versions of Python & other such languages ported to embedded systems, but they tend to be the embedded Linux variety. Depending on your platform (no idea if it's a little MCU with 8K ROM or an embedded PC) that might be an option.


问:
Authentication for users on a Single Page App?
I have developed a single page app prototype that is using Backbone on the front end and going to consume from a thin RESTful API on the server for it's data.

Coming from heavy server side application development (php and python), I have really enjoyed the new different design approach with a thick client side MVC but am confused on how best to restrict the app to authenticated users who log in.

I prefer to have the app itself behind a login and would also like to implement other types of logins eventually (openid, fb connect, etc) in addition to the site's native login. I am unclear how this is done and have been searching - but unsuccessful in finding information that made it clear to me.

In the big picture, what is the current best practice for registering users and requiring them to login to use your single page app?

Once a user is logged in, how are the api requests authenticated? Can I store a session but how do I detect for this session in the API calls? Any answers to this would be much appreciated!

答:
In the big picture, what is the current best practice for registering users and requiring them to login to use your single page app?

I would look at OAuth option to free users from registration process. It is a new era where users do not want spent time to deal with creating a new account for each sites that they visit. Instead, they look  forward to get instant access and do their job :)

Currently, most social media pages do have OAuth and that is one of important factors that drives users to their site. Thus, i see a big trend toward abandoning all rude force registration processes and using OAuth API's instead.


问:
What are the benefits and drawback of documentation vs tutorials vs video tutorials
Which types of learning resources do you find the most helpful, for which kinds of learning and/or perhaps at specific times?

Some examples of types of learning you could consider:

When starting to integrate a new SDK inside an existing codebase

When learning a new framework without having to integrate legacy code

When digging deeper into an already-used SDK that you may not know very well yet

For example - (video) tutorials are usually very easy to follow and tells a story from beginning to end to get results, but will nearly always assume starting from scratch or a previous tutorial.  Therefore such a resource is useful for quick learning if you don't have legacy code around, but less so if you have to search for the best-fit to the code you already have.

SDK Documentation on the other hand is well-structured but does not tell a story.  It is more difficult to get to a specific larger result with documentation alone, but it is a better fit when you do have legacy code around and are searching for perhaps non-obvious ways of employing the SDK or library.

Are there other forms of resources that you find useful, such as interactive training?

答:
This is highly subjective based on the person.

I'm an intuitive learner, I have to stick my hands into something and wiggle them about, get cut and bit to learn. So I go straight to the documentation to find the knobs and wheelies I can turn. But for many, this method is as good as tea leaves.

I think based on the way education systems tend to teach people (at least the one I'm familiar with, and I think many follow similarly) it is more common for people to have a learning style suited to tutorials. For many however these simply are not effective.

Some people learn very well from visual such as in a video tutorial, while many learn better from reading tutorials.

I'm not sure you're goal here, but I guess my point is:

If you must generate training, use all 3.

If you are looking for a technique to learn, use the one which you find works best for you.


问:
Is the book "Structure and Interpretation of Computer Programs" a good read for Java programmers?
This may be subjective and likely to be closed but I still wanted to know if its really helpfull to read Structure and Interpretation of Computer programs.

Structure and Interpretation of Computer Programs

The book does not use Java. Not that I wanted to learn Java. I am just curious as to know if it be will useful read to be a better programmer and what are the things that I can gain from the book or are their any other alternatives to this book more suited to Java programmers?

答:
I'm going to go out on a limb here and say - probably not a good read for most people - whatever language.

Like Knuth it's a good book to have read.  However even assuming you are a hot-shot MIT ugrad it will still take the best part of a year to read properly, and thats with lecturers and TAs helping.

Are there other books on software engineering you could read in that time that would be of more value? Are there other languages you could learn in the time ?

edit Just to expand a little:

Software engineering is engineering, it's all about optimisation. Your task is to maximise your knowledge for a given time+cost budget.

SICP is a high level introduction to programming through a functional language. The reason it uses a functional language is that it's easier to describe a lot of mathematical concepts of programming in functional languages than in procedural ones and a lot easier to read than formal logic.

There is also a certain amount of posturing ie. "You aren't really a programmer unless you read SICP", or Knuth, or can program in Lisp, or C, or x86 assembler. That's normally easy to refute; ie. you can't be a real programmer unless you know Cantor's work on set theory and Maxwell's equations and are familiar with hole mobility in semiconductors.


答:
It will depend!

The right answer will really depend on type of technology/framework that you are trying to promote or learn.

For example, a series of blog posts about new emerging framework/technology might be interesting for some developers, while others may enjoy watching tutorial videos and/or webcasts.

Thus, it is really subjective question and it is hard to say what will work and what not. Because, you are dealing with human preferences on over another. I guess polling of this question may provide you a better result.

However, taking into account the effort to learn, I would rate it as "documentation < tutorial < video tutorial".

Title: What are the benefits and drawback of documentation vs tutorials vs video tutorials

Body:
Which types of learning resources do you find the most helpful, for which kinds of learning and/or perhaps at specific times?

Some examples of types of learning you could consider:

When starting to integrate a new SDK inside an existing codebase

When learning a new framework without having to integrate legacy code

When digging deeper into an already-used SDK that you may not know very well yet

For example - (video) tutorials are usually very easy to follow and tells a story from beginning to end to get results, but will nearly always assume starting from scratch or a previous tutorial.  Therefore such a resource is useful for quick learning if you don't have legacy code around, but less so if you have to search for the best-fit to the code you already have.

SDK Documentation on the other hand is well-structured but does not tell a story.  It is more difficult to get to a specific larger result with documentation alone, but it is a better fit when you do have legacy code around and are searching for perhaps non-obvious ways of employing the SDK or library.

Are there other forms of resources that you find useful, such as interactive training?


答:
From my understanding SICP, it is more focused in areas of functional programming, including recursive programming, and strong introduction to CS - which is a bit hard to grasp to a new programmers. Another point, it is prepared and instructed in for MIT, and some good fundamentals in engineering field, math, physics is also needed to find this book useful.

I would advice a good set of books where each focus on different aspects of software engineering:

Code Complete 2 - focuses on the processes of software engineering.

Clean Code - focuses on coding in the small. How to write classes and functions.

Pragmatic Programmer - focuses on working within a team producing software.

More detailed description of mentioned books above and other once can be found from the following references:

How to be a Programmer with 10 Simple Books

Best books for beginning programmers

Please, feel free adding to the list as it is not ideal one :)

Edit: In choosing above mentioned books, and determining priority of how to read them, it is really comes down to the purpose on what you are primary trying to do or learn.

Title: Is the book "Structure and Interpretation of Computer Programs" a good read for Java programmers?

Body:
This may be subjective and likely to be closed but I still wanted to know if its really helpfull to read Structure and Interpretation of Computer programs.

Structure and Interpretation of Computer Programs

The book does not use Java. Not that I wanted to learn Java. I am just curious as to know if it be will useful read to be a better programmer and what are the things that I can gain from the book or are their any other alternatives to this book more suited to Java programmers?


问:
What should be the minimal design/scope documentation before development begins?
I am a junior developer working on my own in the programming aspect of projects.

I am given a png file with 5-6 of the pages designed, most times in specific detail. From this I'm asked to develop the back end system needed to maintain the website, usually a cataloging system with products, tags and categories and match the front end to the design.

I find myself in a pickle because when I make decisions based on assumptions about the flow of the website, due to a lack of outlining details, I get corrected and am required to rewrite the code to suit what was actually desired.

This process happens multiple times throughout a project, often times on the same detail, until it's finally finished, with broken windows all through it.

I understand that projects have scope creep, and can appreciate that I need to plan for this, but I feel that in this situation, I'm not receiving enough outlining details to effectively plan for the project, resulting in broken code and a stressed mind.

What should be the minimal design/scope documentation I receive before I begin development?

答:
I think, the fundamental issue is in communication, not in documentation.

In addition, clarifying client and business needs with product owner/BA (or PM if there is no business analysts) in your organization through effective communication will ease your life and in great help you to deliver good results with less dramatic change sets.

As you may also know, Agile Software Development is targeting the mentioned goals above and you may find more information from this reference .


问:
API Auth vs User Auth
I have read many posts and articles on this topic but still cant connect the dots. I want to make a Rails app that is strictly a JSON API maybe using Sinatra or the rails-api gem. I also want to make both a web client app and an iPhone app which consumes the API. No plans on letting third party dev's use it.

So I could create a separate username/password combination for both the web and mobile client and use HTTP Basic over SSL. Each app would have these values as configs in the source and use it to authenticate to the API so only these can make a call. Anyone else trying would get a 401 error returned. This would be considered handling the API authentication.

The web and mobile client apps allow end users to sign up and read/write data to the API. When each user is created, I create and save a token in their profile. If a user successfully signs in, I send back the token. On each future read/write then also send along this token in the header. I get the token and lookup the user in the database and make the read/write.

Does this sound like an appropriate way to handle it. For the web client, when I initially send back the token, where do I store it. In a cookie? Do I also drop a cookie to handle session state?

答:
I am looking to implement a similar approach.  The technologies are different, but the concepts are the same.

Basically, I have:

ASP.NET MVC 4 web application, using OAuth (which I think uses the DotNetOpenAuth API)

ASP.NET Web API (REST), in same "space" as above, authorization via header token

Mobile Device Application, authenticates via OAuth

When the Mobile Device Application authenticates via OAuth, I provide a callback to a method in the Web API which checks that the user exists and has access, and returns a generated token.

Subsequent calls by the Mobile Device Application to the Web API sends the token in the header (over SSL) and thus gets authorized or not per call.

In this case we're not persisting the token beyond the current active session, after which the user would have to authenticate again.

OAuth used in this example, but it could be any other authentication mechanism, which provides a token which would then be used for authorization.

This sounds like the same solution that you're looking at and seems to work fine during some initial testing.

Update: the following is a very good reference for this type of thing: WPF Application With Live ID, Facebook, Google, Yahoo!, Open ID

Title: API Auth vs User Auth


问:
Possible to switch table at runtime using Entity Framework?
I have code to switch between databases when using EF, but now also need to allow the user to choose a particular table. (The tables all use the same schema but may have different names because of the way the client updates datasets). Is there a way to do this? And if it's done can it be done without being broken by updates being made to the Entity data model?</p>

答:
This blog post goes into some detail: Changing Entity Framework model at runtime. It's apparently fairly difficult.

Out of the box there is no way, or at least not an easy one, to change table or schema names used by the Entity Framework at runtime...

On CodePlex however you can find an adapter for your Entity Framework model to change it at runtime. You can change the connection to the database, change table names or use different schemas...

So we’re all set to support multi tenancy? Not quite...

For a multi tenant application we need a different model for each of our customers so we need to make another change to the code as available in the CodePlex project. If you don’t mind taking the performance hit to rewrite the mapping every single time an object context is created you can just open the ConnectionAdapter class and change the static variables which hold the model information to instance variables...


问:
How to manage github issues for (priority, etc)?
I'm new to github, and am looking for advice on how to manage issues.  I'm used to having priority and other ordering options but see that none exist.

How do others manages issues during the lifecycle of a bug/feature?

Thanks in advance.

答:
In addition to the tagging solutions suggested above, we have blocking and blocked as labels.

An issue must first be assigned to the correct person, but if that person is unable to work on the issue until some other issue is finished, the issue is marked as blocked. And the other issue is referenced using a hash tag.

Similarly if a task is blocking someone else from working on something, it should be marked as blocking with a reference to the other issue.

I found it a little tricky to figure out how to list items assigned to a particular person;

The solution is to click on the 'search' icon (with no search criteria typed in) and on the results page there is a drop-down on the left.

OwnerDisplayName: djf


答:
There are various theories about how people learn. On the other hand, most programmers have some things in common: We generally don't have much time, and we are good at reading.

Nothing makes me more mad than trying to find information about a framework/sdk/library to see if it will have any use for me in a 2 hour long video.

Here is a common strategy:

A basic overview on what it does(article, video)

Comparison with similar stuff(article)

Detailed API documentation(articles)

Beginner tutorials(articles, video)

Cookbooks(articles, video)

My advice, go with articles/documentation, and add some videos/screencasts when you have more time.


答:
For what you have described, FORTH is probably ideal.  FORTH routinely runs on much smaller platforms than yours.  (16K total is a big machine for FORTH.)  There is going to be some serious learning curve involved, if you've never looked at FORTH before.

There's a Scheme implementation called TinyScheme (as I recall), that might be worth a look.  I first heard about it from a piece on Slashdot, about a guy who used it as the core of his malware engine.  (Yeah, that's right: His job was writing malware, for something or other, and doing it in TinyScheme meant their payload could be a lot smaller.)