做更多的事,用更少的{}
这是 GHOST_URL/do-more-with-less/ 的中文版。没写完之前可以看原版哦。
{}在这里代表什么?
- 更少的 engineering
- 更少的学习成本
- 更少的代码
- 更少人手
- 更少的时间
- 更少的头疼
- 更少 ...
Yes , new technologies and software engineering concepts were brought to the community, we can actually do more with less ...
New technologies:
These technologies include:
MongoDb
With MongoDb you no longer need:
ORM
With MongoDb you can save JSON data in collections, no need to convert datas back and forth any more.
SQL
Quering data in Mongo collection is much easier. NO security issue like Sql injection to concern with. No sql efficiency & performance headache. life lit up!
Cache system such as Redis, Memche
MongoDb can act like Cache system. So forget the Redis & Memche maintenance and learning curve.
Profound Db table design skill
You just save JSON data in Mongo collections, no need to care the fields are Int/String/Char/Double and their length etc...
And forget the relationship in relational databases. In relational databases , if you want to save an order, you need order table, order_item table, order_item_attribute table. And you need Procedure to maintain consistency. Now just all of these, since you can save orders in a single Mongo collection in JSON format.
Of course , there still a little schema design, and indexing to manage, but much easier.
Profound Master/salve architecture and so on
Is the mysql/oracle cluster, sharding , scalling esay to manage? Haha, with MongoDb it become much easier.
Quoted:
For CIOs:
MongoDB can help you make a difference to the business. Tens of thousands of organizations, from startups to the largest companies and government agencies, choose MongoDB because it lets them build applications that weren’t possible before. With MongoDB, these organizations move faster than they could with relational databases at one tenth of the cost. With MongoDB, you can do things you could never do before.
For Architects:
MongoDB can make you a hero to the business, ops, and engineering without compromising on risk. The business gets to see its projects done faster than ever before. Ops gets a system that lets them sleep through the night and meet SLAs with 10% of the budget. Engineering gets a database that developers love to use. And you get to do things you could never do before, like turn on a dime when business needs change.
For DBA & Ops:
MongoDB is the system you worry about the least and enjoy managing the most. It lets you sleep through the night. It fits into your existing infrastructure and processes. It lets you deploy and upgrade with one click and no downtime. It scales natively and handles failover on its own. It runs in the cloud or on commodity hardware in your data center. And it saves you budget.
For developers:
We built a database that developers love. MongoDB makes working with a database simple and elegant. It uses a JSON data model that maps to your applications, and has dynamic schemas that let you iterate quickly. It has drivers for the languages you use to code. And it has an expressive query language that lets you get, set, sort and aggregate data without writing extra code. We even made it easy to deploy, provision, and scale.
Docker
The Docker philosophy: Build, Ship, and Run Any App, Anywhere.
B4 Docker era, it takes days to set up Project development environment that consist of Apache, PHP,Mysql,Redis,Node, Java/Android. And it might still end up with :
It work on my local machine, but not the test engineer's and the production Servers
What's harder is that, some developer / test engineer preferred to work on Mac, some preferred Windows, some Linux ... , not to mention the GUI-less production Servers . How much time have we wasted on dealing with environments and runtime!
With Docker, the life saver. Once set up , you can Build, Ship, and Run you app on Any OS with a few or even one single command:
docker-compose up -d
No more wikis, READMEs, long runbook documents and post-it notes with stale information. Teams using Docker know that their images work the same in development, staging, and production.
And let Apache, PHP,Mysql,Redis,Node, Java/Android runing on their own isolated containers.
And the docker swarn scale very easy.
Left lit up!
Knowledge reuse
Express , Zend expressive & Spark
You see:
From Express framework for node (http://expressjs.com/) :
var express = require('express')
var app = express()
app.get('/', function (req, res) {
res.send('Hello World!')
})
app.listen(3000, function () {
console.log('Example app listening on port 3000!')
})
From PHP Framework zend-expressive (https://docs.zendframework.com/zend-expressive/):
use Interop\Http\ServerMiddleware\DelegateInterface;
use Zend\Diactoros\Response\TextResponse;
use Zend\Expressive\AppFactory;
require 'vendor/autoload.php';
$app = AppFactory::create();
$app->get('/', function ($request, DelegateInterface $delegate) {
return new TextResponse('Hello, world!');
});
$app->pipeRoutingMiddleware();
$app->pipeDispatchMiddleware();
$app->run();
From Java framework Spark (http://sparkjava.com/ ) :
import static spark.Spark.*;
public class HelloWorld {
public static void main(String[] args) {
get("/hello", (req, res) -> "Hello World");
}
}
This is the routing and middleware concept, you can see how easy your Knowledge can be reuse !
For Old Mvc: Adonisjs
(http://adonisjs.com/docs/3.2/overview)
The routing and Middleware concept stem from Express framework for Node. To catch up with this trending concept, moving away from the old Java and PHP and into the Node world is a smart choice i think.
But developers from from the old Java and PHP were used to work with full stack framework comes with full solutions such as:
- Powerful ORM to make secure SQL queries.
- API & Session based Authentication System.
- Easy way to send emails via SMTP or Web Service (Mailgun, Mandrill, etc.)
- Validate & Sanitise every user’s inputs.
- Strong emphasis on security.
- Extendable application layout.
- And so on ...
Express framework for Node doesn't offer those.
Now time to combine the old but yet powerful full-stack MVC with new , edge and trending routing and middleware concept!
Adonisjs offer routing and middleware as easy as:
const Route = use('Route')
const User = use('App/Model/User')
Route.get('/', function * (request, response) {
const users = yield User.all()
response.json(users)
})
And your familiar ORM model ,controller & view:
const User = use('App/Model/User')
class UsersController {
//the Route:
//Route.get('users', 'UsersController.index');
* index (request, response) {
const users = yield User.all() //User is an ORM model
yield response.sendView('users', { users: users.toJSON() })
//the view
/*
{% for user in users %}
<h2>{{ user.username }}</h2>
{% endfor %}
*/
}
*Take this as transitional solution move from the old/legacy to new modern solution only - move to mongo and drop the complex ORM + relational databases; And middleware is more flexible than controller *
Angular2
Angular2 is another "do more with less.. weapon ". mobile, web, native mobile and native desktop, browser/ server render, PWA(progressive web app) all in one! Plz see :
https://angular.io/
And the learning curve is low. Even if you are from the backend (server-side) development,I believe the Angular2's concepts : MVC, Router, Service, dependency injection & RX etc. are quite familiar for you.
Angular2 + nativescript, React Native Vs. Ojective C + Java
Still have different teams developing for web, Andoid and iOS? I'm afraid that's costly ;) ! Try https://www.nativescript.org/ , especially when you have Angular2 skill.
Or http://facebook.github.io/react-native/ from big company Facebook
Electron
For the pass year I've been working for a startup. We considered outsourcing an ERP. A proposal from
an outsourcing company : a B/S + C/S architect, and the client in C/S is base on Win Form, which doesn't run on Mac, and take additional charge to devlope a client for Mac. This is costly for a startup. Why not go with https://electron.atom.io/
Also : conver C and C++ code to javascript : http://kripken.github.io/emscripten-site/
Others
For PHP developer want to try Javascript or Node:
http://locutus.io/php/