Welcome to the libuv API documentation -- libuv API documentation



Welcome to the libuv API documentation — libuv API documentation

  • Full-featured event loop backed by epoll, kqueue, IOCP, event ports.
  • Asynchronous TCP and UDP sockets
  • Asynchronous DNS resolution
  • Asynchronous file and file system operations
  • File system events
  • ANSI escape code controlled TTY
  • IPC with socket sharing, using Unix domain sockets or named pipes (Windows)
  • Child processes
  • Thread pool
  • Signal handling
  • High resolution clock
  • Threading and synchronization primitives


Read full article from Welcome to the libuv API documentation — libuv API documentation


Apache zookeeper 翻译之简介(一) | 并发编程网 - ifeve.com



Apache zookeeper 翻译之简介(一) | 并发编程网 - ifeve.com


Read full article from Apache zookeeper 翻译之简介(一) | 并发编程网 - ifeve.com


How to end the session in spring 3 - Stack Overflow



How to end the session in spring 3 - Stack Overflow

think the common problem when using @SessionAttributes is after you invalidate your current session, Spring MVC attach the model attributes back into the new session -- hence causing the impression it never invalidates

You can check the value of JSESSIONID before & after you invalidate it. You will get a brand new JSESSIONID, yet previous model attributes are attached straight into the new session

I found myself having to do this to wipe a model attribute of name "counter" from session after invalidating it


Read full article from How to end the session in spring 3 - Stack Overflow


5 Weird Java Questions That Will Make Your Head Spin | Takipi Blog



5 Weird Java Questions That Will Make Your Head Spin | Takipi Blog

Some of the weirdest Java puzzlers that we had a chance to get our hands on Even the most experienced Java developers will find the questions in this post confusing. Or at the very least, amusing (And absolutely unfair). After our adventure with the Java Deathmatch we've decided to publish a different set of questions this time around, highlighting some of the unusual and quirky things you can do with Java. For the results of our previous quizzes, you can check out this post and see if you can solve the question that 4 out 5 of developers got wrong. Do try this at home (or office). But please, please don't use it in real life Java applications! Unless you're trying to troll someone and in that case, everything goes. A huge huge thanks goes out to Peter Lawrey for sharing most of these questions with us. The solutions are available at the bottom of this post, but try giving them an honest try and see how many of them you manage to explain. New Post:

Read full article from 5 Weird Java Questions That Will Make Your Head Spin | Takipi Blog


Nerves rattled by highly suspicious Windows Update delivered worldwide [Updated] | Ars Technica



Nerves rattled by highly suspicious Windows Update delivered worldwide [Updated] | Ars Technica

by Dan Goodin - Sep 30, 2015 6:27 pm UTC Microsoft said a highly suspicious Windows update that was delivered to customers around the world was the result of a test that wasn't correctly implemented. "We incorrectly published a test update and are in the process of removing it," a Microsoft spokesperson wrote in an e-mail to Ars. The message included no other information. The explanation came more than 12 hours after people around the world began receiving the software bulletin through the official Windows Update, raising widespread speculation that Microsoft's automatic patching mechanism was broken or, worse, had been compromised to attack end users. Fortunately, now that Microsoft has finally weighed in, that worst-case scenario can be ruled out. What follows is the remainder of this post as it appeared before the company issued its explanation. This Web search , which queries the random-appearing string included in the payload,

Read full article from Nerves rattled by highly suspicious Windows Update delivered worldwide [Updated] | Ars Technica


Google, Twitter Set to Unveil 'Instant Articles' Version Next Week | Re/code



Google, Twitter Set to Unveil ‘Instant Articles’ Version Next Week | Re/code

Re/code Event Updates Re/code Product Updates http://on.recode.net/1KSF1mI Trending Everett Collection / Shutterstock Share: Three weeks ago, we told you about plans Google was hatching to launch a publishing tool to serve up articles on mobile devices. It would look similar to Facebook’s Instant Articles feature, only Google would cull articles from cached versions on search, rather than hosting it themselves, and would release it as an open source tool to other platforms. Its first big platform partner was Twitter. Earlier today, Google sent out an invite for a press event in New York next Wednesday for “a new open source initiative for the mobile Web.” Presumably, that’s when we’ll hear more details about the program, like which publishers are signed up and, just maybe, the business terms of the arrangements. Thus far, the New York Times and the Guardian have said they will be partners. Along with Facebook,

Read full article from Google, Twitter Set to Unveil ‘Instant Articles’ Version Next Week | Re/code


Top 5 Node.js books money can buy



Top 5 Node.js books money can buy

Top 5 Node.js books money can buy

  1. Practical Node.js by Azat Mardan takes you from installing all the necessary modules to writing full-stack web applications by harnessing the power of the Express.js and Hapi frameworks, the MongoDB database with Mongoskin and Mongoose, Jade and Handlebars template engines, Stylus and LESS CSS languages, OAuth and Everyauth libraries, and the Socket.IO and Derby libraries, and everything in between.
  2. Node.js in Action by Mike Cantalon shows you how to build production-quality applications. Clear introductions of key concepts and example-by-example coverage take you from setup to deployment. You'll dive into asynchronous programming, data storage, and output templating, and interact with the filesystem to create non-HTTP applications like TCP/IP servers and command-line tools. No prior experience with Node.js needed.
  3. Node.js the Right Way by Jim R. Wilson packs a hefty dose of Node.js. You'll test your code's functionality and performance under load, learn important aspects of Node development -- from architecture and core, to its ecosystem of third-party modules. You'll discover how Node pairs a server-side event loop with a JavaScript runtime to produce screaming fast, non-blocking concurrency. Through a series of practical programming domains, you'll use the latest available ECMAScript Harmony features and harness key Node classes such as EventEmitter and Stream.
  4. Node.js, MongoDB, and AngularJS Web Development by Brad Daley is a complete guide for web programmers who want to integrate these three technologies into full working solutions. It begins with concise, crystal-clear tutorials on each of the three technologies and then quickly moves on to building scalable, high-performance web applications.
  5. Pro Node.js for Developers by Colin J. Thrig will teach you advanced software engineering skills that will give your code a professional edge. You'll learn how to create easily reusable modules that will save you time through code reuse, to log and debug your applications quickly and effectively and to write code that will scale easily and reliably as the demand for your application grows.

Read full article from Top 5 Node.js books money can buy


软件架构分解



软件架构分解

架构分解的原则

德国哲学家、数学家莱布尼兹一针见血地指出:"不讲分解技巧,分而治之就不大有用。无经验者对问题分解不当,反而会增加困难"。为了正确的进行分解,需要遵循一些分解原则:

  • 低耦合、高内聚:莱布尼兹指出:"分解的主要难点在于怎么分。分解策略之一是按容易求解的方式来分,之二是在弱耦合处下手,切断联系"。在弱耦合处下手,切断联系。太精辟了!高内聚、低耦合也是软件设计的基本原则,软件设计中的很多设计原则其实都可以认为它的派生或具体化,如单一职责原则、依赖倒置原则、模块化封装原则,这些原则在架构分解中也是适用的。
  • 层次性:分解通常是先业务后技术,循序渐进,先逻辑后物理,从上到下逐级进行分解展开:系统->子系统->模块->组件->类。
  • 正交原则:和物理学中的正交分解类似,架构分解出的架构元素应是相互独立的,在职责上没有重叠。
  • 抽象原则:架构元素识别,在较大程度上是架构师抽象思维的结果,架构师应该具备在抽象概念层面进行架构构思和架构分解的能力。
  • 稳定性原则:将稳定部分和易变部分分解为不同的架构元素,稳定部分不应依赖易变部分。根据稳定性原则,将通用部分和专用部分分解为不同的元素;将动态部分和静态部分分解为不同的元素;将机制和策略分离为不同的元素;将应用和服务分离。
  • 复用性原则:就是对知识的重用.重用类似系统已有的架构设计、设计经验、成熟的架构模式或参考模型、设计模式、领域模型、架构思想等,因为它们已经在不同的层次上分解识别出了许多架构元素,或者指出了一些分解方向,对我们的架构分解具有借鉴和指导作用。例如 IBM SOA 解决方案参考模型对 SOA 服务化具有重要的指导意义,我们可以参照它对系统进行初步的架构分解。

Read full article from 软件架构分解


左棍圣母F叔对《可扩展的艺术》的笔记(2)



左棍圣母F叔对《可扩展的艺术》的笔记(2)

我们假设经理应负的基本职责包括以下三点:确保给工程师分配了项目,无论是自己分配的,还是根据管理层指示分配的;确保执行了行政工作,如解决了薪资问题或者传达了人事信息等;以及接收项目的状态更新信息,以便报告给高级管理层。考虑到这种基础水平的管理职责,一个新近从工程师升到管理层的初级经理可能会发现,即使只管理 6 个人的团队,行政工作和项目管理的工作都会耗费她一整天的时间。... 比起那些做过一遍又一遍的工作来说,新工作通常需要花费更多时间,而且要求更加专注。在决定一个团队的最佳规模时,经验水平是一个要考虑的关键因素。
一般来说,业务责任人和产品经理都想建立更多更大的面向客户的项目,这样他们才能不停地击败竞争对手,扩大收益来源,拓展客户基础。这时团队规模过小会带来两个主要问题。首先,根据所采用的产品开发生命周期方法不同,较大的项目需要更多的迭代或更长的开发时间。... 其次,如果增加了工程师数量,那么支持人员的数量也随之增加,包括经理的人数。
工程师天生会对自己能够完成的工作保持过分乐观的态度,如果他们推脱过去能够完成的工作量,这会是一个明显的信号,说明他们自觉生产力下降了。
比这个难得多的是在团队规模过大时,拆分团队。如果团队拆分不当,会造成可怕的后果,如代码的所有权不清楚、更难以沟通、重新适应新经理而工作压力增大。... 首先需要关注的是代码或工作,我们将在第三部分详细地讨论故障域这个概念,这些域通过隔离服务,从而限制了故障的影响范围,也许拆分团队是个把代码拆分到故障域的好机会。

Read full article from 左棍圣母F叔对《可扩展的艺术》的笔记(2)


Programming Communications: Java Design Pattern : Service Provider Interface and Factory method



Programming Communications: Java Design Pattern : Service Provider Interface and Factory method

It is common to accomodate multiple service providers while designing an API. Each service provider may implement a use-case that will be used by API client applications. For example, Java security has a number of providers SunJCE, BKS etc which provide security operations such as encryption. Two common patterns that come into play involve defining service provider interfaces, factory classes/methods to get the appropriate target object. Service provider interface is implemented by the service provider classes and there may be more than one type of class that provides a functionality like encryption. There are DESCipher, AESCipher etc all of which implement CipherSpi which is the service provider interface definition. Again the Cipher engine class encapsulates a CipherSpi and creates the appropriate cipher through its factory method getInstance(). The provider list is usually read from a configuration file. Here we use a simple example to demonstrate spis, spiImpls.

Suppose we want a logger. We can define the logger spi which has the functionalities that we want from a logger. We provide two implementations of this spi and annotate the classes with spiImpl. This annotation is not  mandatory. The class name can be anything but, if name conventions are followed then, code becomes maintainable in addition to being simpler. The engine class can be Logger which takes a string parameter which specifies whether we need a File based logger or a Console logger. The Logger class acts like a factory for creating Logger classes and allows client apps to perform logging through it. Although this is a small example, it gets the idea across. SPI, SPIImpl classes are very frequently used in Java 2 Enterprise projects just like Facade pattern. The spi pattern allows us to add different types of providers and also implementations of the interface.

Read full article from Programming Communications: Java Design Pattern : Service Provider Interface and Factory method


Do Not Make This Mistake When Developing an SPI | Java, SQL and jOOQ.



Do Not Make This Mistake When Developing an SPI | Java, SQL and jOOQ.

Most of your code is private, internal, proprietary, and will never be exposed to public. If that's the case, you can relax – you can refactor all of your mistakes, including those that incur breaking API changes.

If you're maintining public API, however, that's not the case. If you're maintaining public SPI (Service Provider Interfaces), then things get even worse.

The H2 Trigger SPI

In a recent Stack Overflow question about how to implement an H2 database trigger with jOOQ, I have encountered the org.h2.api.Trigger SPI again – a simple and easy-to-implement SPI that implements trigger semantics. Here's how triggers work in the H2 database:


Read full article from Do Not Make This Mistake When Developing an SPI | Java, SQL and jOOQ.


Main Page - APIDesign



Main Page - APIDesign

I created this website when the Practical API Design book (describing all the design mistakes I did when designing NetBeans) was published to be a source of latest on-line news from the world of API Design. I still publish my observations about APIDesignPatterns or various APITypes, but I am also trying to cover other projects of mine like Bck2Brwsr or DukeScript. Here is the overview of most recent topics that I blogged about:


Read full article from Main Page - APIDesign


Service Provider Interface: Creating Extensible Java Applications - Developer.com



Service Provider Interface: Creating Extensible Java Applications - Developer.com

An application is an aggregation of cohesive services. While an application offers a broader set of functionality in terms of application programming interfaces (APIs) and classes, a service provides access to some specific application functionality or feature. The service defines the interfaces for the functionality and a way to retrieve an implementation. For example, consider an application that provides a variety of information about a geographical location, such as real estate data, weather information, demographics, etc. The weather service, a part of the application, may define only the interface for retrieving the weather information (more on this example shortly).

A service provider interface (SPI) is the set of public interfaces and abstract classes that a service defines. A SPI may be represented by a single interface (type) or abstract class or a set of interfaces or abstract classes that define the service contract.


Read full article from Service Provider Interface: Creating Extensible Java Applications - Developer.com


java - difference between SPI and API? - Stack Overflow



java - difference between SPI and API? - Stack Overflow

  • the API is the description of classes/interfaces/methods/... that you call and use to achieve a goal and
  • the SPI is the description of classes/interfaces/methods/... that you extend and implement to achieve a goal

Put differently, the API tells you what a specific class/method does for you and the SPI tells you what you must do to conform.

Usually API and SPI are separate. For example in JDBC the Driver class is part of the SPI: If you simply want to use JDBC, you don't need to use it directly, but everyone who implements a JDBC driver must implement that class.

Sometimes they overlap, however. The Connection interface is both SPI and API: You use it routinely when you use a JDBC driver and it needs to be implemented by the developer of the JDBC driver.


Read full article from java - difference between SPI and API? - Stack Overflow


DevFaqApiSpi - NetBeans Wiki



DevFaqApiSpi - NetBeans Wiki

API is a general term - an acronym for Application Programming Interface - it means something (in Java, usually some Java classes) a piece of software exposes, which allows other software to communicate with it.

SPI stands for Service Provider Interface. It is a subset of all things that can be API specific to situations where a library is providing classes which are called by the application (or API library), and which typically change the things the application is able to do.

The classic example is JavaMail. Its API has two sides:

  • The API side — which you call if you are writing a mail client or want to read a mailbox
  • The SPI side if you are providing a wire-protocol handler to allow JavaMail to talk to a new kind of server, such as a news or IMAP server

Users of the API rarely need to see or talk to the SPI classes, and vice-versa.

In NetBeans, when you see the term SPI, it is usually talking about classes that a module can inject at runtime which allow NetBeans to do new things. For example, there is a general SPI for implementing version control systems. Different modules provide implementations of that SPI for CVS, Subversion, Mercurial and other revision control systems. However, the code that deals with files (the API side) does not need to care if there is a version control system, or what it is.


Read full article from DevFaqApiSpi - NetBeans Wiki


5 things you didn't know about ... everyday Java tools



5 things you didn't know about ... everyday Java tools

2. ServiceLoader

Java developers frequently wish to decouple the knowledge necessary to use a component from the knowledge necessary to create one. This is typically accomplished by creating an interface describing the actions the component can perform, and using some kind of intermediary to create the component instances. Many developers use the Spring framework for this purpose, but there's another approach that is even more lightweight than a Spring container.

The ServiceLoader class from java.util can read a configuration file tucked away in a JAR file and find implementations of an interface, then make those implementations available as a list of objects to choose from. If you needed a personal-servant component to carry out your tasks, for instance, you could acquire one with the code in Listing 2:


Read full article from 5 things you didn't know about ... everyday Java tools


ServiceLoader Dynamic Reloading on JEE7 Web Application



ServiceLoader Dynamic Reloading on JEE7 Web Application

We had a technical discussion about updating an application on the fly in Java EE. There were a couple of issues that we were trying to resolve. One was a simple way to add functionality to a web application while deployed, and update the running application. It could be functionality like a new module, or service, or something like, the classic example for the ServiceLoader, codecs.

Additionally, we needed to be able to add the functionality without adding another framework to make it happen. It needed to be something that was available in the existing Java SE/EE APIs. Again, the ServiceLoader seemed to be a possible solution.

I did a Proof of Concept (POC) for using a ServiceLoader to accomplish adding additional services to our application. That worked, but required a restart of the server, or a reload of the application at a minimum. This assumes that the application was NOT auto-deployed. It turns out that worked, but really was only a half-measure. I wanted to see if I could solve the dynamic reloading part, and I did.

Solution

Before we see the code, how does it work in general. We use the ServiceLoader which is part of the Service Provider Interface (SPI) functionality of Java. It is a hidden gem for those who need it, and framework creators can take advantage of this simple, easy to use technology. The ServiceLoader is managed by a Singleton that returns an instance of the ServiceLoader that will return our SPI implementations. In my example, I create an interface that is packaged separately in its own jar and is shared between the deployed web application and the service implementations. The ServiceLoader loads this interface and makes the implementations available. The cool part is that our Singleton class also has some cool NIO and NIO.2 help with the ZipFileSystemProvider to load the implementations from newly added jars. It also has some demo of how to use a URLClassLoader to add our new implementations and update the ServiceLoader.

Read full article from ServiceLoader Dynamic Reloading on JEE7 Web Application


My Technical Notes: Java ServiceLoader Example



My Technical Notes: Java ServiceLoader Example

Java ServiceLoader Example

Defining an API and developing the corresponding implementation has become an uber mainstream practice when developing large Java applications. Modularization is such an useful design principle, especially to avoid spaghetti code, for testing and debugging, and for re-implementation of old code.

Many developers seek to separate API interfaces and abstract classes from their implementation in separate packages. Yet, this almost always leads to cycles between java packages (api refers to impl, and vice-versa). There has been many frameworks, such as OSGi, supporting modularization, but the documentation has not always been good and complete. Many developers have struggled with class loading issues too.

Fortunately, Java has delivered the ServiceLoader utility since release 6. The example described in this post is available from Github in the Java-ServiceLoader directory. It is inspired from here.

Read full article from My Technical Notes: Java ServiceLoader Example


一分钟了解Storm



一分钟了解Storm

基础部分


过去的数十年中,数据处理领域有着重大的变革。MapReduce和Hadoop以及相关技术使得存储和处理过去无法想象的规模的数据。不幸的是,这些数据处理技术并不是实时性的,也没有把Hadoop改造成实时数据处理的系统;实时数据处理相对于普通的批处理有基本的不同和需求。


然而,实时的对大规模的数据处理已经是现代诸多业务迫切需要的了,缺少实时性的Hadoop日益成为实时处理生态的查克琉斯之踵。


这个时候,Storm来了。


在Storm之前,我们需要手工来构建一个网络队列和执行单元来进行实时处理。执行单元要处理队列里面的消息,更新DB,然后将处理完的消息发送至其他队列以供以后的处理。不幸的是,这种方式有严重的限制:


1,冗余:我们要花大部分的时间来配置消息的去向、部署执行单元、部署队列之间的消息流动。这样以来实时处理逻辑成为了我们所有工作的很小的一部分。

2,脆弱:容错性很低,执行单元和队列任务消息必须由我们自己保证。

3,可扩展性很差:当消息对于单一的执行单元和队列累积过多的时候,我们就需要将数据分区处理。这个时候我们又需要重新配置新的执行单元和消息流向,而新的部分将有可能会失败。


尽管队列和执行单元对于大量消息处理的时候可能会失败,消息处理显然是实时计算的基础部分。问题是:我们怎么样草能做到不丢失数据,对大规模消息处理的时候扩展性好,并且容易操作呢?


Storm是用来干这事的。


为什么Storm是重要的


Storm提供了用于实时计算的一个集合的基元。类似于MapReduce大大简化了并行批处理,Storm大大简化了并行实时计算。


Storm的关键特性:

1,极其广泛的应用范围:Storm可以用来处理消息和更新DB(流式处理),对数据流的持续查询然后将结果数据流返回给客户端(持续计算),并行处理巨大的查询(分布式RPC),Storm的这些特性满足很多种应用场景。

2,可伸缩性:Storm扩展起来可以每秒处理大量的消息。扩展成为拓扑结构,我们需要做的只是增加机器,增加拓扑结构的并行机制配置。一个Storm扩展的例子,初始的时候应用有10个节点,每秒能够处理100万个消息,包括拓扑结构每秒数百次的DB操作。Storm借助ZK对集群进行协调,使得扩展集群的大小很容易。

3,保证无数据丢失:一个实时系统必须要保证数据消息被成功的处理。对于删除数据的系统来说应用范围比较窄。Storm保证每个消息都被处理,这个可以和S4系统进行对比。

4,极其健壮:不像Hadoop系统,难以管理这点是臭名昭著的,而Storm不是这样的,它可以很好的工作。为了能够让Storm项目对于用户来说有更好的用户体验,这也是Storm致力于做的一点。

5,容错性:如果在执行计算的时候出现错误,Storm将会重新调度任务,Storm可以保证计算一直进行,除非我们将它kill掉。

6,支持语言多:强健和易伸缩实时处理系统不应该受限于平台。Storm拓扑和处理组件可以使用任何语言来定义和操作。


Read full article from 一分钟了解Storm


Constants in Java - The Anti-Pattern - DZone Java



Constants in Java - The Anti-Pattern - DZone Java

Generally we see a need of a constants file in an application, which stores constants to be shared across multiple locations. While designing an app, I came across a similar situation, where we required various constants to be used at multiple places across the application.

I was sure, that I need a separate file which stores public static constants. But I wasn't very sure to make it an Interface or a Class. (Enum was not suitable for my requirement). So I had two options to chose from:


Read full article from Constants in Java - The Anti-Pattern - DZone Java


打造高性能JAVA应用你需要知道的 - ImportNew



打造高性能JAVA应用你需要知道的 - ImportNew

对于性能调优,通常会有三个步骤:1,性能监控;2,性能剖析;3,性能调优

我们对于操作系统的性能关注主要在下面几个点上:CPU利用率、CPU调度执行队列、内存利用率、网络I/O、磁盘I/O。

1,CPU利用率

对于一个应用来说,为了让应用达到最好的性能和可扩展性,我们不仅仅要充分利用CPU周期内可用的部分,而且要让这部分CPU的使用更有价值,而不是浪费。能够让CPU的周期利用的更充分对于多线程应用运行在多处理器和多核系统上至很有挑战性的。另外,当CPU达到饱和状态的时候并不能说明CPU的性能和伸缩性已经达到了最佳的状态。为了区分应用是如何利用CPU资源的,我们必须从操作系统级别来检测。在很多操作系统上,CPU的利用率统计报告通常包括用户和系统或内核对操作系统的使用。用户对CPU的使用是指应用用来执行应用代码执行所需要的时间。相比之下,内核和系统对CPU的使用是指应用用来执行操作系统内核代码锁花费的时间。高的内核或者系统CPU使用率可以表明共享资源紧迫,或者是有大量的I/O设备交互。理想的状态为了提高应用的性能和伸缩性,让内核或系统CPU时间为0%,因为花在执行内核或系统代码的时间是可以用来执行应用代码的。因此CPU使用优化的一个正确方向就是尽可能减少CPU花在执行内核代码或者系统代码上的时间。


Read full article from 打造高性能JAVA应用你需要知道的 - ImportNew


Top 8 Diagrams for Understanding Java



Top 8 Diagrams for Understanding Java

A diagram is sometimes worth 1000 words. The following diagrams are from Java tutorials on Program Creek, they have received the most votes so far. Hopefully, they can help you review what you already know. If the problem is not clear by the diagram itself, you may want to go to each article to take a further took.

1. String Immutability

The following diagram shows what happens for the following code:

String s = "abcd";  s = s.concat("ef");

Read full article from Top 8 Diagrams for Understanding Java


8张图理解Java - ImportNew



8张图理解Java - ImportNew

一图胜千言,下面图解均来自Program Creek 网站的Java教程,目前它们拥有最多的票选。如果图解没有阐明问题,那么你可以借助它的标题来一窥究竟。

1、字符串不变性

下面这张图展示了这段代码做了什么

1
2
String s = "abcd";
s = s.concat("ef");

Read full article from 8张图理解Java - ImportNew


Multidimensional Array Traversal in Java - DZone Java



Multidimensional Array Traversal in Java - DZone Java

Multidimentional Arrays

An array is a container object in Java that holds a fixed number of values of a single type. The length of an array is established when the array is created. After creation, its length is fixed. e.g. an array of size 10 is defined below:

public class ArrayDemo {
private int arraySize=10;
public int[] arrayOfIntegers = new int[arraySize];
}

The above code is an example of single dimentional array. In other words the array grows only in one direction. Many a times we need arrays that grow in more than one dimention. Such arrays are called multi-dimentional arrays. For simplicity, let's talk about a 2-D array. 2-D arrays are very useful when we need a matrix or x-y plots/graphs. Below is an example of a square 2-D array.


Read full article from Multidimensional Array Traversal in Java - DZone Java


Java 多维数组遍历 - ImportNew



Java 多维数组遍历 - ImportNew

数组是Java中的一种容器对象,它拥有多个单一类型的值。当数组被创建的时候数组长度就已经确定了。在创建之后,其长度是固定的。下面是一个长度为10的数组:

1
2
3
4
public class ArrayDemo {
    private int arraySize=10;
    public int[] arrayOfIntegers = new int[arraySize];
}

上面的代码是一维数组的例子。换句话说,数组长度只能在一个方向上增长。很多时候我们需要数组在多个维度上增长。这种数组我们称之为多维数组。为简单起见,我们将它称为2维数组。当我们需要一个矩阵或者X-Y坐标系的时候,二维数组是非常有用的。下面就是一个二维数组的例子:


Read full article from Java 多维数组遍历 - ImportNew


Difference between Thread and Process - 我的博客 - ITeye技术网站



Difference between Thread and Process - 我的博客 - ITeye技术网站

  The major difference between threads and processes is: Threads share the address space of the process that created it; processes have their own address space. Threads have direct access to the data segment of its process; processes have their own copy of the data segment of the parent process. Threads can directly communicate with other threads of its process; processes must use interprocess communication to communicate with sibling processes. Threads have almost no overhead; processes have considerable overhead. New threads are easily created; new processes require duplication of the parent process. Threads can exercise considerable control over threads of the same process; processes can only exercise control over child processes. Changes to the main thread (cancellation, priority change, etc.) may affect the behavior of the other threads of the process; changes to the parent process does not affect child processes. © 2003-2015 ITeye.com. All rights reserved.

Read full article from Difference between Thread and Process - 我的博客 - ITeye技术网站


fahd.blog: Logback: Change root logger level programmatically



fahd.blog: Logback: Change root logger level programmatically

A couple of years ago, I wrote about how it is possible to change log4j logging levels using JMX. I'm now using logback, which is intended to be the successor of log4j and provides several advantages over it.

The following code snippet can be used to change the root logger's logging level in logback:

import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
 
Logger root = (Logger)LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
root.setLevel(Level.DEBUG); //change to debug

Read full article from fahd.blog: Logback: Change root logger level programmatically


Google's New Nexus Phones, Pixel C Tablet, And More: Your 2-Minute Guide | Fast Company | Business + Innovation



Google's New Nexus Phones, Pixel C Tablet, And More: Your 2-Minute Guide | Fast Company | Business + Innovation

Google's New Nexus Phones, Pixel C Tablet, And More: Your 2-Minute Guide Google's newest gadgets include the Nexus 5X smartphone, the Pixel C tablet, and an upgraded Chromecast. Here's what you should know about Google's new products. Read More: The 12-megapixel camera on the Nexus 5X can shoot 4K video, much like the iPhone 6s and 6s Plus, which started shipping to Apple customers last week. Apple is known for having a superior camera on its phones, so it will be interesting to see these two cameras tested side by side. The Nexus 5X starts at $379 and will ship in late October. The Nexus 5X has a fingerprint sensor on the back of the phone. The Nexus 6P sports a bigger, 5.7-inch display (similar to the iPhone 6S Plus) and all-metal body. Like its smaller counterpart, the Nexus 6P has a rear camera that vows to give Apple a run for its money: a large, 12.3 megapixels, 4K video, and the option to shoot video in slow motion. The Nexus 6P starts at $499 for the 32 GB model. Unlike Apple,

Read full article from Google's New Nexus Phones, Pixel C Tablet, And More: Your 2-Minute Guide | Fast Company | Business + Innovation


Google unveils everything Apple launched, but cheaper - MarketWatch



Google unveils everything Apple launched, but cheaper - MarketWatch

4,517 -26.65 -0.59% S&P 500 1,884 +2.32 +0.12% 6:59 P.M. ET 5:00 P.M. ET 4:54 P.M. ET 4:52 P.M. ET 4:51 P.M. ET 4:51 P.M. ET 4:50 P.M. ET 4:50 P.M. ET 4:39 P.M. ET Share Google announces Nexus 5X and 6P smartphones, new Chromecast devices and enterprise-focused Pixel C tablet Getty Images This tablet is trying to hang with the iPad and Surface Pro iPhone 6S and iPhone 6S Plus. Refreshed Apple TV. Enterprise-focused iPad Pro. Nexus 5X and Nexus 6P. Refreshed Chromecast. Enterprise-focused Pixel C tablet. Those lineups show the similarities between the new products Google Inc. GOOG, +0.01% GOOGL, -0.26% announced Tuesday and those Apple Inc. AAPL, -3.01%   announced earlier this month . The big difference between the two companies' new offerings is price, with Google undercutting Apple across the board. Smartphones Google introduced two new Android smartphones , the Nexus 5X and Nexus 6P, at a product event on Tuesday. Both phones — manufactured by LG and Huawei,

Read full article from Google unveils everything Apple launched, but cheaper - MarketWatch


Sony's big PlayStation 4 update arrives tomorrow



Sony's big PlayStation 4 update arrives tomorrow

Sony's big PlayStation 4 update arrives tomorrow by Steve Dent | @stevetdent | 11 hours ago September 29th 2015 9:24 am Sony is set to release one of its biggest updates ever for the PlayStation 4, and now we know when it's coming: tomorrow, September 30th. Update 3.0 includes some significant new changes, especially if you want more streaming options and extra online storage. You'll soon be able to broadcast or watch games on YouTube Gaming, send 10 second highlight clips to Twitter and "Request to Share Play and Broadcast" a friend's game or gaming session. Storage on PlayStation Plus has also gone up dramatically from 1GB to 10GB. Other new feature include a PS4 events app that gives you a calendar for new games and other items, the ability to create gaming communities and "Live from PlayStation," a hub for the latest screenshots, clips and news. The update will roll out tomorrow, but in the meantime, Sony has detailed the bulk of changes in its blog post and the video below.

Read full article from Sony's big PlayStation 4 update arrives tomorrow


AngelikaLanger.com - Java Generics FAQs - Under The Hood Of The Compiler - Angelika Langer Training/Consulting



AngelikaLanger.com - Java Generics FAQs - Under The Hood Of The Compiler - Angelika Langer Training/Consulting

This is a collection of answers to frequently asked questions (FAQs) about Java Generics, a new language feature added to the Java programming language in version 5.0 of the Java Standard Edition (J2SE 5.0).

If you want to provide feedback or have any questions regarding Java generics, to which you cannot find an answer in this document, feel free to send me EMAIL or use the GENERICS FAQ form.


Read full article from AngelikaLanger.com - Java Generics FAQs - Under The Hood Of The Compiler - Angelika Langer Training/Consulting


Planning Department Confirms 75 Percent Of Academy Of Art Buildings Are Illegal: SFist



Planning Department Confirms 75 Percent Of Academy Of Art Buildings Are Illegal: SFist

The day's most popular stories from SFist every evening in your inbox from our newsletter. Istaverse Open external links in tabs Planning Department Confirms 75 Percent Of Academy Of Art Buildings Are Illegal by Jay Barmann in News on Sep 28, 2015 11:30 am Photo: Wikimedia Following on Forbes Magazine's recent takedown of the Academy of Art University and their fast-and-looseness with real estate zoning, and in anticipation of their long-delayed Environmental Impact Report, the Planning Department has issued a new report that breaks down the uses, legal and illegal, of the AAU's 40 buildings citywide. It turns out that of the 40, only 10 are being used for purposes that their currently approved for, while 30 are operating illegally, many of them as student housing. The city is sensitive to the loss of residential space that this represents, and as Socketsite notes , there are nine properties that could not even be approved for their new uses under current planning code.

Read full article from Planning Department Confirms 75 Percent Of Academy Of Art Buildings Are Illegal: SFist


ECJ advisor says data transfer deal between EU and US is invalid - Business Insider



ECJ advisor says data transfer deal between EU and US is invalid - Business Insider

Europe just caused a massive headache for American tech companies   A top European lawyer made a decision this morning that could prove a massive headache for American tech companies in Europe. Advocate General Yves Bot, an advisor to the European Court of Justice (ECJ) has said the "safe harbour" agreement for transferring data between the US and EU is "invalid," because of concerns over US spying. Bot's opinion isn't legally binding, and the ECJ judges will make a formal ruling in the coming months. But as The Irish Times notes , the judges follow such opinions "in most cases." But if the 15-year-old legal agreement between the EU and the US is suspended by the ECJ, it could have significant consequences for American tech companies in Europe. It would open them up to significantly more scrutiny from privacy watchdogs within Europe, some of which have the power, according to Bots , to "[suspend] the transfer of that data." Companies like Google and Facebook,

Read full article from ECJ advisor says data transfer deal between EU and US is invalid - Business Insider


Microservices Architecture pattern



Microservices Architecture pattern

Pattern: Microservices Architecture

Context

You are developing a server-side enterprise application. It must support a variety of different clients including desktop browsers, mobile browsers and native mobile applications. The application might also expose an API for 3rd parties to consume. It might also integrate with other applications via either web services or a message broker. The application handles requests (HTTP requests and messages) by executing business logic; accessing a database; exchanging messages with other systems; and returning a HTML/JSON/XML response.

The application has either a layered or hexagonal architecture and consists of different types of components:

  • Presentation components - responsible for handling HTTP requests and responding with either HTML or JSON/XML (for web services APIS)
  • Business logic - the application's business logic
  • Database access logic - data access objects responsible for access the database
  • Application integration logic - messaging layer, e.g. based on Spring integration.

There are logical components corresponding to different functional areas of the application.


Read full article from Microservices Architecture pattern


An introduction to reactive programming



An introduction to reactive programming

There has been a significant shift in recent years towards server-side and network programming using event-driven asynchronous runtime environments and frameworks such as Node.js, Twisted, and Netty/NIO. Asynchronous code allows independent IO operations to run concurrently, resulting in efficient code. However, this improved efficiency comes at a cost — straightforward synchronous code may become a mess of nested callbacks.

Can we do better? Can we combine the simplicity of synchronous code with the efficiency of the asynchronous approach? It turns out we can. Futures are an abstraction that allow us to express the effect of latency in asynchronous computations, encapsulate event-handling code, and use higher-order functions such as map, reduce, and filter, to compose clean and readable asynchronous code.


Read full article from An introduction to reactive programming


What is difference between observer pattern and reactive programming? - Stack Overflow



What is difference between observer pattern and reactive programming? - Stack Overflow

Reactive programming, at least how I understand it, is the general term behind easily propagating changes through the execution of a prorgam. It's not a specific pattern or entity per-se, it's an idea, or style of programming. It's the concept that when x changes in one location, the things that depend on the value of x are recalculated and updated in various other locations with a minimum of fuss.

The observer pattern (at least in OO languages) is a common method for providing a "trigger" to allow information to be updated whenever such a change is made (or, in more common OO terms, when an "event" is fired.) In that sense, it provides a mechanism for allowing the concept of reactive programming to happen in OO (and sometimes other) style languages.


Read full article from What is difference between observer pattern and reactive programming? - Stack Overflow


What is difference between observer pattern and reactive programming? - Stack Overflow



What is difference between observer pattern and reactive programming? - Stack Overflow

Reactive programming, at least how I understand it, is the general term behind easily propagating changes through the execution of a prorgam. It's not a specific pattern or entity per-se, it's an idea, or style of programming. It's the concept that when x changes in one location, the things that depend on the value of x are recalculated and updated in various other locations with a minimum of fuss.

The observer pattern (at least in OO languages) is a common method for providing a "trigger" to allow information to be updated whenever such a change is made (or, in more common OO terms, when an "event" is fired.) In that sense, it provides a mechanism for allowing the concept of reactive programming to happen in OO (and sometimes other) style languages.


Read full article from What is difference between observer pattern and reactive programming? - Stack Overflow


100+ Free Books on Data Science, Big Data, Data Mining, Machine Learning, Python, R, and more



100+ Free Books on Data Science, Big Data, Data Mining, Machine Learning, Python, R, and more

Pulled from the web, here is a great collection of eBooks (most of which have a physical version that you can purchase on Amazon) written on the topics of Data Science, Business Analytics, Data Mining, Big Data, Machine Learning, Algorithms, Data Science Tools, and Programming Languages for Data Science.

While every single book in this list is provided for free, if you find any particularly helpful consider purchasing the printed version. The authors spent a great deal of time putting these resources together and I'm sure they would all appreciate the support!


Read full article from 100+ Free Books on Data Science, Big Data, Data Mining, Machine Learning, Python, R, and more


Prisoners and the lightbulb puzzle



Prisoners and the lightbulb puzzle

There are 10 prisoners are in 10 different cells of a prison. There is no way in which they can communicate with each other. Each night, the warden picks one of the 10 prisoners and that prisoner is supposed to spend the entire night in the central living room. There is one bulb in the living room which can be switched on or off. Warden puts a condition, "If any of the prisoner can tell with certainty, that all the other prisoners have spent night in the central living room, then he will free all of them. But, If the prisoner says that all the other have spent night in the living room, but that is not true, then all the prisoners will be killed". Thus, the assertion should only be made if the prisoner is 100% certain of its validity. Before the random picking begins, the prisoners are allowed to get together and make some strategy. But, once the strategy is made, then a prisoner cannot communicate with any other prisoner. What plan should they agree on, so that eventually,

Read full article from Prisoners and the lightbulb puzzle


代码重构方向原则指导 - xiyf2046的专栏 - 博客频道 - CSDN.NET



代码重构方向原则指导 - xiyf2046的专栏 - 博客频道 - CSDN.NET

重构是一种对软件进行修改的行为,但它并不改变软件的功能特征,而是通过让软件程序更清晰,更简洁和更条理来改进软件的质量。代码重构之于软件,相当于结构修改之于散文。每次人们对如何对代码进行重构的讨论就像是讨论如果对一篇文学作品进行修订一样无休无止。所有人都知道应该根据项目的自身情况来对代码进行重构,而重构是无止境的。莫扎特从来不不对他的作品进行修订,特罗洛普对自己作品修订的恰到好处,大多数作家认为他们俩这样做都是合适的,但他们的合适对于你我来说未必是合适的。

最常见的基本重构方法可以归纳为两个方向。通过归纳方法将一个长的过程分解为小的可以重用的组件,和通过内联(inline)方法来消除那些不够份量的小方法。我们可以提炼方法来让大量的子类共享相同的功能特征,我们可以下放方法来让只有用到这些功能的子类才知道它们的存在。重构就是爬山,通过一步一步的小的提高来逐渐的改进整体的质量,但在重构时,我们如何知道哪种方法是上山的正确道路?

关于代码地形学的这个问题公认的方法有两种。去除有异味的代码重构成模式。如果能做到这样,当然是很好的。就像是纠正作文里的一个语法错误或不恰当的比喻。如果我们可以找到这些四处隐藏的有异味的代码,将它们重写成整洁的,条理的,结构化的形式,何乐而不为。但这些都是特殊情况。如果没有明显的模式来重构,或没有很直接的方法来去除代码异味,那该怎么办呢?

这才是我们如今编程艺术的中心问题,而很少人讨论这些。通常我们讨论这些问题时都是罗列出更多更长的有异味的代码模式的清单,但这并不是解决问题的方法。代码异味应该是我们公认的不好的东西,而不是那些置之不理也无妨的事情。我们经常会说到老板不给我们重构的机会,甚至代码有明显的异味,老板们认为这是浪费时间。并不是每个人都有懂软件的老板。我很吃惊为什么只有很少的讨论谈到点子上。。也许我这篇文章才说到问题关键处。

我的观点,当重构没有现成的明显的方向时,我们可以遵循下面的原则:

  1. 当属性、方法或类存在任何的需要复用的意向时,归纳提炼它们。
  2. 不要低估小方法对代码整洁的作用。使用小方法能让你节省很多笔墨。
  3. 能让代码长度变短的提炼都应该去提炼,包括注释。
  4. 用switch()代替多形――即使这样做会使代码变长。
  5. 用封装控制可见度。
  6. 消除依赖。
  7. 简化构造方法――即使这样做会使代码变复杂。
  8. 封装或避免条件表达式。使用guard语句,避免使用else语句。
  9. 使用常量代替魔幻数字。
  10. 不确定时,偏向使用组合而不是继承。
  11. 不确定时,将计算操作移入到这些数据的所有者对象里,或将数据移动到执行计算操作的对象里(也就是迪米特法则(Law of Demeter))。
  12. 使用小对象,松耦合,避免大对象,高聚合。
  13. 不确定时,偏向使用递归而不是循环。
  14. 使用代理对象,模拟对象和辅助对象来隔离网络,数据库,文件和用户接口。
  15. 不确定时,尽量在model里添加代码,必要时才往controler添加代码。view里添加的都应该是便捷功能和简写方法,但不要局限于此。
  16. 偏向使用apply, each, mapcar,而不是loop.
  17. 尽量使用新技术。

Read full article from 代码重构方向原则指导 - xiyf2046的专栏 - 博客频道 - CSDN.NET


软件架构---学习小语之一 - xiyf2046的专栏 - 博客频道 - CSDN.NET



软件架构---学习小语之一 - xiyf2046的专栏 - 博客频道 - CSDN.NET

软件是运行在操作系统上执行某些任务的程序、过程和文档。sun公司的分类:应用软件、开发工具,系统软件。

 

2 软件架构师(Achitect)执行架构过程(Achitcting)产生架构(Achitecture)。


3 软件架构师是参谋长,是指导员,是政治部主任;软件架构师是不是军长。


4 系统四个要素:硬件和软件构成计算机系统、组织、信息。


5 软件开发是以用例驱动的,以架构为中心,迭代与增量的开发。


6 架构是政治、经济、技术三种因素共同的结果。


7 高度决定视野,角度决定观念,尺度把握人生。


8 不能追求完美的架构,寻找合适的架构。


9  涉众的关注点组成试点。


10 架构是战略,设计模式是战术,那编码就是冲锋陷阵了。


11 类之间关系:是一个(is),有一个(has),用一个(use)。


Read full article from 软件架构---学习小语之一 - xiyf2046的专栏 - 博客频道 - CSDN.NET


API优先架构或者胖瘦服务器之争 - xiyf2046的专栏 - 博客频道 - CSDN.NET



API优先架构或者胖瘦服务器之争 - xiyf2046的专栏 - 博客频道 - CSDN.NET

自2007年Apple发布了iPhone,网络应用及网站在小屏幕上的呈现机会显著的增高,从而各大网站及机构不得不对其应用进行适当的改变。然而考虑到数据体积、应用程序扩展性、新特性的发布及维护等问题,应用程序的架构也不得不按需进行改变,比如Twitter的面向服务。近日leaseweblabs上发表了一篇文章,详述了API优先架构。

以下为译文:

在API优先架构中,API用户会被视为应用程序的主要用户。这意味着API不会再作为MVC中View的替代,它将拥有最高的优先权。其中最主要的区别就是:在"API优先"中,架构会始终执行一个完整、响应式及文档化的API。而当目标指向移动(应用联连接到API)、代理商(表示层会使用API)及高整合、解耦的多产品环境中,这一点尤为重要。

MVC

MVC架构已经流行了很长一段时间,在2004年RoR发布后,MVC变得愈加炙手可热。在MVC情况下用户和员工分别使用前端和后端两个不同部分,可以大幅提高应用程序中组件的重用率。合适的使用MVC策略,可以让应用程序的很多部分都得以重用,其中包括DBAL/ORM、Business Logic、Presentation及AAA。AAA(Authentication、Authorization、Accounting)允许员工模拟用户行为,使用相同的登录界面及共享日志设备。


Read full article from API优先架构或者胖瘦服务器之争 - xiyf2046的专栏 - 博客频道 - CSDN.NET


浅谈软件架构师的素质与职责 - xiyf2046的专栏 - 博客频道 - CSDN.NET



浅谈软件架构师的素质与职责 - xiyf2046的专栏 - 博客频道 - CSDN.NET

沟通能力和自我表达

我认为沟通能力是基本中的基本,最为重要,最为普遍的素质。技术人员好像容易忽略,想成为架构师就不能忽略。因为架构师要做的第一件事就是与团队成员、项目经理、客户认同沟通,获得认同。我知道,这对于现在做技术,以后想转做架构的人也许很难.对本人也是如此。也许 你会注意到虽然你兢兢业业,老黄牛的做了很多事,但每次升迁的总是那些平时最活跃的人。抛除其他方面的因素,领导之所以选这种人,是因为领导认为他能与人打交道――也就是沟通,而我只能做事,只是个好员工。虽然我自认为也擅长沟通,但没有表现出来,别人如何得知。沟通是双向的,一方面要能够理解对方的意思,另一方面也要让对方理解你的意思。所以如果要成为架构师,首先要勇于表达自我,然后仔细聆听对方的话语。不可抱有"酒香不怕巷子深"的观点,不然结果就是"怀才不遇,图子伤悲"了。

有一定的魄力和感染力

架构师要与很多人打交道,其中不乏领导,刁钻的客户,技术狂人。而架构师是有职无官,但又要推动整个团队的技术进展,能在压力下作出关键性的决策,并将其贯彻到底。这就需要架构师具有一定的魄力和感染力,依此来排除工作过程中一些个人情绪带来的影响,从而保证工作顺利进行。其实这点就算不做架构师,在日常生活中,相信大家也有所体会。面对有感染力的人,他哭你悲,他伤你哀;面对有魄力的人的铿锵话语,相信他的话你不会不听;反之,面对一个亦步亦趋,唯唯诺诺的人,你如何敢相信他的话,又如敢与他共事!

有广阔的知识领域

架构师的职责有些特殊,多少有点需要创新的要求。虽然有很多现成的架构,但放到具体行业又有不同,不能生搬硬套。那么这时候你就需要专业的架构知识,丰富的业务领域知识,开阔的眼界。依此才能跳出架构和业务,从旁看清楚事实,从而将理论架构与实际业务完美结合。我认为,要做的这点,架构师不仅要努力学习架构和业务知识,也要把眼光放得更远。"世事洞明皆学问",也许灵感正来自与软件毫不相干的东西。

有过硬的技术能力和丰富的编程经验

广阔的知识领域是广度的要求,因为没有广度就成了井底之蛙。然而有了广度还要有深度。人的精力有限,但至少要精通1~2门技术。有深度才能把握细节,才能保证自己的设计不是天马行空,不切实际。有丰富的编程经验,主要是希望保持一种代码感觉,能够和开发人员进行有效的沟通,了解团队的情况。当然这并不是要求自己成为一门技术专家,只要能够保持对代码的感觉就行。因为优秀的技术选型可能有很多,适应于团队的缺未必。

多方位思考分析能力

收集到客户需求和技术团队的反馈后,就要求架构师能够对这些资料进行系统分析,制订可行的解决方法。制订可行的架构,不仅要求你要从客户的角度考虑,也要从开发,机器等多方面考虑。这就要求你具备一定的抽象思维,多方位分析能力。只有具备这样的能力,架构师才能看清系统整体,掌控全局。如何具备这些能力?首要的是经验,自己的,别人的均可,这点最重要。创新固然让人兴奋,然前人之鉴才更为稳妥,另外,相信大家都听过"听君一席话,胜读十年书"这句话,由此可知经验有多么重要;其次要学习。

当我们具备了这些条件的时候就可以选择成为架构师了。这时候我们就应该知道软件架构师应该做些什么,不应该做些什么,也就是软件架构师的职责范围。

由于国内外软件土壤差别巨大,适合国外的一些理论在国内不一定行的通,而国内的一些资料往往都是根据国外的资料直接搬过来用的,这也直接导致国外的软件架构师在国内变得水土不服。今天本篇随笔的内容则是在一些培训资料的基础上,加上自己的思考,总结出来的适合国情的软件架构师职责范围。

需求整理分析

有人认为架构师是在需求规格说明书完成后介入的,但我认为架构师要从项目最开始的阶段就参与进来。理由有很多:首先,第一手的信息损失最少,架构师能够更好的把握需求;其次,分析人员在与客户交流时,往往不会深入挖掘需求,因为有很多隐藏的需求客户自己都不见得意识的到,而架构师则可以依靠敏感的软件嗅觉发现这些需求,减少以后的变数;第三,分析人员往往脱离开发团队,盲目接受客户需求,而架构师能够清楚把握现有的研发团队能做什么,不能做什么,提前预知风险,降低项目失败的机率。

系统分解

在收集完信息后,架构师需要将用户需求转化为软件需求,同时要补充非业务需求,如健壮性,扩展性等等。如何区分和化解用户需求与软件需求,如何有效把握用户需求与软件需求的区别,是系统分解的核心。这是最考验架构师的地方,也是只有架构师参与的工作。

技术选型

这一步要根据对软件需求决定项目该使用何种架构,开发模型,及依赖选项。如使用多层架构还是分布式架构,是瀑布模型还是RUP,是使用MySQL还是SQLServer,是否需要使用企业库,是否需要使用ORM。但是,架构师对项目的技术选型要提供多种不同的方案,并为每种不同方案提供详细说明文档,用来阐述每种方案的优势,劣势,可行性等内容。这些文档供项目经理或领导决策最终的技术选型。

系统设计

依据软件需求和技术选型,架构师需要和软件工程师一起将软件需求落实到软件详细设计说明书中。架构师负责将软件需求分解,重组织为子项目,子系统,组件和模块,以及它们之间的逻辑关系,从而形成不同的逻辑组成部分,最后还需要确定各个子系统及组件间的接口。这些都是作为进一步的团队分工的依据。同系统分解一样,系统设计是考验架构师能力的重要职责。

培训与指导

在软件详细设计说明书完成后,为保证项目的顺利进行,架构师需要对整个团队进行技术培训,让团队中的每个人明白自己的职责范围,该做什么,不该做什么。在项目实施过程中,架构师需要参与到具体开发过程中,给与每个开发人员有效指导,以避免团队成员对系统设计的误解而造成项目的延误。在我看来,这点对于新手比较多的团队尤为重要。因为国内新手的一个通病是眼高手低,刚学会了一点点就认为自己什么都会;当他们拿到真正的设计时又往往不知所措,畏首畏尾。

保持沟通

沟通是保证项目顺利开展的有效保障。架构师要从多方面跟踪项目进度,及时与项目经理或直属领导汇报项目进展,与技术开发人员沟通遇到的问题,如果是迭代开发,还需要与用户沟通需求变更。

以上是一个项目开发过程中架构师需要承担的主要职责,相比一些培训指导,我认为,架构师需要更深入地参与到项目中。


Read full article from 浅谈软件架构师的素质与职责 - xiyf2046的专栏 - 博客频道 - CSDN.NET


架构师不可不知的十大可扩展架构 - xiyf2046的专栏 - 博客频道 - CSDN.NET



架构师不可不知的十大可扩展架构 - xiyf2046的专栏 - 博客频道 - CSDN.NET

对于大多数架构师而言,"可扩展性"在软件架构方面是最虚无缥缈的说法。这毫不奇怪,因为可扩展性正是如今软件设计领域最值得优先考虑的要素。然而,计算机科学家们还无法了解一套单独的架构如何才能扩展至各类应用环境当中。相反,我们在数量繁多的方案中所设计出的可扩展性架构,往往以业界较为通用的已知可扩展模式及个人偏好为标准。简单来讲,打造一套具备可扩展性的系统已经变得更像是一门艺术而不单单是技术。

我们常常会通过观摩杰作体会并学习艺术的精髓,而可扩展性也应该遵循同样的路线!

在这篇文章中,我将列出数款为大家所耳熟能详的可扩展性架构。通常情况下,架构师们完全可以借鉴已知的可扩展架构模式,进而创造出新的可扩展架构。

  1. LB (负载平衡器) + 无共享单位 - 该模型中包含一系列单元,各单元彼此间不共享任何内容,且一致指向一个将输入文讯按一定条件发往单元处的负载平衡器(这构成一个循环,以负载等情况为基础)。每个单元可以是一个单独的节点或是紧密耦合的节点所构成的集群。用户可以使用DNS循环、硬件负载平衡器或者软件负载平衡器达成负载平衡效果。创建一套负载均衡的层次结构,并在其中结合前面提到的各种负载平衡器也是可行的。在由Michael Stonebraker撰写的《 无共享体系架构实例 》一文中,专门讨论了此类架构。
     
  2. LB + 无状态节点 + 可扩展存储 - 传统的 三层式Web架构 使用的就是这种模型。该模型包括数个与可扩展存储交互的无状态节点以及一个分布于节点间负载中的负载平衡器。在这一模型中,存储通常作为限制因素存在,但NoSQL存储则可以利用这套模型创建出具备相当可扩展性的系统。
     
  3. 点对点架构 (分布式Hash列表 (简称DHT)以及内容寻址网络(简称CAN)) -这套模型提供了一些传统的可扩展算法,这些算法的各个方面几乎全部按对数进行了等比例增加。举例来说,像Chord、Pastry(特指免费版)以及CAN都属于此类。而以Cassandra为代表的、基于P2P架构的几款NoSQL系统也是其中的成员。《 展望P2P系统中的数据 》一文就深入探讨了这类模型的各种细节。
     
  4. 分布式队列 �C 这种模型以将队列实施(即先进先出交付机制)作为网络服务处理为基础。该模型通过JMS队列而广泛得到采用。一般会遵循这种做法的有任务队列以及通过保持队列分级体系实现扩展性的任务队列版本,后者在负载无法及时处理时,任务会由低级层面向高级层面传递。
     
  5. 发布/订阅模式 - 一般用于通过网络向彼此发布订阅讯息。《 发布与订阅的多面性 》这一经典论文中详细的介绍这一模型,该模型方面最典型的例子即 NaradaBroker与 EventJava 
     
  6. 小道消息与自然灵感式模型 - 这种模型源自日常生活中小道消息的传播途径,也就是每个节点将随机选择后续节点以交换信息。正如现实生活中的实际反馈,这种八卦型算法在信息传播方面出奇地迅速。该模型的另一大分支则是受到生物学影响的启发式算法。自然世界中存在着大量协调及扩展方面极为卓越的固有算法。举例来说,蚂蚁、人类以及蜜蜂等等,都能够以最简洁的交流方式协调好扩展性方面的需要。模型中的算法正是借鉴了这些实际存在的现象。在论文《 从流行病的蔓延到分布式计算 》中对这种模型有着详尽的叙述。
     
  7. 地图缩小/数据流 - 这一概念首先由谷歌公司提出,地图缩小为工作的描述及执行提供了一套可扩展的模式。虽然内容简单,但它仍然成为联机分析处理方面的首要处理模式。数据流则是一种更先进的方式,用来表达执行信息;而像Dryad及Pig这样的项目为数据流的执行提供了可扩展的框架。论文《 地图缩小:大型集群上的简化数据处理 》中设置了专门的主题,详细讨论这一内容。Apache的Hadoop就是这种模型的代表性产品。
     
  8. 责任树形图 - 这种模型打破了递归问题的束缚,将整个流程以树状形式加以处理;每个父节点将工作下放至子节点。这种模型扩展性强,并已经被应用于数款可扩展性架构当中。
     
  9. 流处理 - 这种模型被用于处理源源不断的数据流及数据。这种处理方式通过网络中的处理节点获得支持(例如Aurora、Twitter Strom以及Apache S4等)。
     
  10. 可扩展存储 �C 该模型的应用范围从数据库、NoSQL存储、服务注册到文件系统都有体现。 链接中的这篇文章 以可扩展性为切入点对其进行了深入讨论。

综上所述,可扩展性的实现只有三种方式,即:分布、缓存及异步处理。前文所提到的各种架构事实上都是把这三种方式进行不同组合并加以实施。而另一方面,不利于可扩展性的因素,除了糟糕的编码本身,全局性协调也起到了重要的影响。简单来说,任何一种全局性协调都会限制系统的可扩展性。本文中所提到的各种架构也只是在做好了本地性协调,而非全局性协调。

然而,将它们有机地结合起来以创建一套极具可扩展性的架构可不像说起来那么容易,除非我们能找到一种全新的扩展模式。不过经验告诉我们,比起搞一套全新的架构,采用为我们所熟知且更易驾驭的可扩展性解决方案永远是更好的选择。


Read full article from 架构师不可不知的十大可扩展架构 - xiyf2046的专栏 - 博客频道 - CSDN.NET


大型网站架构不得不考虑的10个问题 - xiyf2046的专栏 - 博客频道 - CSDN.NET



大型网站架构不得不考虑的10个问题 - xiyf2046的专栏 - 博客频道 - CSDN.NET

1、海量数据的处理

众所周知,对于一些相对小的站点来说,数据量并不是很大,select和update就可以解决我们面对的问题,本身负载量不是很大,最多再加几个 索引就可以搞定。对于大型网站,每天的数据量可能就上百万,如果一个设计不好的多对多关系,在前期是没有任何问题的,但是随着用户的增长,数据量会是几何 级的增长的。在这个时候我们对于一个表的select和update的时候(还不说多表联合查询)的成本的非常高的。

2、数据并发的处理

在一些时候,2.0的CTO都有个尚方宝剑,就是缓存。对于缓存,在高并发高处理的时候也是个大问题。在整个应用程序下,缓存是全局共享的,然而在 我们进行修改的时候就,如果两个或者多个请求同时对缓存有更新的要求的情况下,应用程序会直接的死掉。这个时候,就需要一个好的数据并发处理策略以及缓存 策略。

另外,就是数据库的死锁问题,也许平时我们感觉不到,死锁在高并发的情况下的出现的概率是非常高的,磁盘缓存就是一个大问题。

3、文件存贮的问题

对于一些支持文件上传的2.0的站点,在庆幸硬盘容量越来越大的时候我们更多的应该考虑的是文件应该如何被存储并且被有效的索引。常见的方案是对文 件按照日期和类型进行存贮。但是当文件量是海量的数据的情况下,如果一块硬盘存贮了500个G的琐碎文件,那么维护的时候和使用的时候磁盘的Io就是一个 巨大的问题,哪怕你的带宽足够,但是你的磁盘也未必响应过来。如果这个时候还涉及上传,磁盘很容易就over了。

也许用raid和专用存贮服务器能解决眼下的问题,但是还有个问题就是各地的访问问题,也许我们的服务器在北京,可能在云南或者新疆的访问速度如何解决?如果做分布式,那么我们的文件索引以及架构该如何规划。

所以我们不得不承认,文件存贮是个很不容易的问题

4、数据关系的处理

我们可以很容易的规划出一个符合第三范式的数据库,里面布满了多对多关系,还能用GUID来替换INDENTIFY COLUMN 但是,多对多关系充斥的2.0时代,第三范式是第一个应该被抛弃的。必须有效的把多表联合查询降到最低。

5、数据索引的问题

众所周知,索引是提高数据库效率查询的最方面最廉价最容易实现的方案。但是,在高UPDATE的情况下,update和delete付出的成本会高的无法想想,笔者遇到过一个情况,在更新一个聚焦索引的时候需要10分钟来完成,那么对于站点来说,这些基本上是不可忍受的。

索引和更新是一对天生的冤家,问题A,D,E这些是我们在做架构的时候不得不考虑的问题,并且也可能是花费时间最多的问题,

6、分布式处理

对于2.0网站由于其高互动性,CDN实现的效果基本上为0,内容是实时更新的,我们常规的处理。为了保证各地的访问速度,我们就需要面对一个绝大的问题,就是如何有效的实现数据同步和更新,实现各地服务器的实时通讯有是一个不得不需要考虑的问题。

7、Ajax的利弊分析

成也AJAX,败也AJAX,AJAX成为了主流趋势,突然发现基于XMLHTTP的post和get是如此的容易。客户端get或者post 到服务器数据,服务器接到数据请求之后返回来,这是一个很正常的AJAX请求。但是在AJAX处理的时候,如果我们使用一个抓包工具的话,对数据返回和处 理是一目了然。对于一些计算量大的AJAX请求的话,我们可以构造一个发包机,很容易就可以把一个webserver干掉。

8、数据安全性的分析

对于HTTP协议来说,数据包都是明文传输的,也许我们可以说我们可以用加密啊,但是对于G问题来说的话,加密的过程就可能是明文了(比如我们知道 的QQ,可以很容易的判断他的加密,并有效的写一个跟他一样的加密和解密方法出来的)。当你站点流量不是很大的时候没有人会在乎你,但是当你流量上来之 后,那么所谓的外挂,所谓的群发就会接踵而来(从qq一开始的群发可见端倪)。也许我们可以很的意的说,我们可以采用更高级别的判断甚至HTTPS来实 现,注意,当你做这些处理的时候付出的将是海量的database,io以及CPU的成本。对于一些群发,基本上是不可能的。笔者已经可以实现对于百度空 间和qq空间的群发了。大家愿意试试,实际上并不是很难。

9、数据同步和集群的处理的问题

当我们的一台databaseserver不堪重负的时候,这个时候我们就需要做基于数据库的负载和集群了。而这个时候可能是最让人困扰的的问题 了,数据基于网络传输根据数据库的设计的不同,数据延迟是很可怕的问题,也是不可避免的问题,这样的话,我们就需要通过另外的手段来保证在这延迟的几秒或 者更长的几分钟时间内,实现有效的交互。比如数据散列,分割,内容处理等等问题

10、数据共享的渠道以及OPENAPI趋势

Openapi已经成为一个不可避免的趋势,从google,facebook,myspace到海内校内,都在考虑这个问题,它可以更有效的留住 用户并激发用户的更多的兴趣以及让更多的人帮助你做最有效的开发。这个时候一个有效的数据共享平台,数据开放平台就成为必不可少的途径了,而在开放的接口 的情况保证数据的安全性和性能,又是一个我们必须要认真思考的问题了。


Read full article from 大型网站架构不得不考虑的10个问题 - xiyf2046的专栏 - 博客频道 - CSDN.NET


关于架构的讨论:烦人的细节 - xiyf2046的专栏 - 博客频道 - CSDN.NET



关于架构的讨论:烦人的细节 - xiyf2046的专栏 - 博客频道 - CSDN.NET

Bob大叔和Simon Brown关于描述系统架构时基础架构(infrastructure)所起的作用展开了讨论。

  在之前标题为 《尖叫的架构(Screaming Architecture)》的文章中,Robert Martin(也就是Bob大叔)阐述了这样的观点:软件产品的架构应该让所有人都很容易了解产品所要达到的目的,并且系统的架构应该反应系统的用例而不是它使用的框架:

架构不是(或者说不应该是)关于框架的内容。架构不应该由框架支持。框架是我们要使用的工具,而不是要符合的架构。如果你的架构基于框架,那么它就无法基于你的用例。

  此外,好的架构应该让我们可以推迟那些不确定的,与框架、数据库、web服务器等等相关的决定,Bob大叔如是说:

好的架构让我们直到项目的后期才需要决定使用Rails,或是Spring,或是Hibernate,或是Tomcat,或是MySql等等。好的架构也让我们能够轻松地改变这些决定。好的架构强调的是用例,并把它与周边的关注点解耦。

  Bob大叔还谈到了互联网,想知道那是否也应该被认为是边缘关注点,并做出结论,网络也是一种"交付机制":

网络是一种交付机制,你的应用程序架构应该这么来对待它。你的应用程序是否通过网络交付是一种细节问题,系统结构不应该取决于此。实际上,你的应用程序是否通过网络交付是你应该推迟考虑的事情。你的系统架构应该尽可能地与如何交付无关。你应该可以把它作为控制台应用程序、web应用程序、富客户端应用程序、甚至是web服务应用程序来交付,而不需要让基本的架构过度复杂或者对其做出变更。

  Bob大叔文章的结论是:你的架构应该告诉读者与系统相关的内容,而不是你在系统中所使用的框架。

  Simon Brown是一位软件架构师,他对Bob大叔关于"交付机制"的观点发表了评论,称之为"烦人的细节"。 他同意Bob大叔所说的系统架构不应该是它所使用的框架,但是他还说到,他希望"看到软件架构能够落地,那就需要包括所选择的实现技术。" 关于推迟决定采用何种基础架构,Brown说到:"如果我们需要做出某些关键的技术决定,那么肯定就需要完成,是吧?",然后他问道:"如果我没有,或者 不能推迟做出决定,那就一定意味着我拥有很差的架构吗? 我们难道不应该把推迟作为一种有意识的决定,而不是一种规则吗?"


Read full article from 关于架构的讨论:烦人的细节 - xiyf2046的专栏 - 博客频道 - CSDN.NET


Labels

Algorithm (219) Lucene (130) LeetCode (97) Database (36) Data Structure (33) text mining (28) Solr (27) java (27) Mathematical Algorithm (26) Difficult Algorithm (25) Logic Thinking (23) Puzzles (23) Bit Algorithms (22) Math (21) List (20) Dynamic Programming (19) Linux (19) Tree (18) Machine Learning (15) EPI (11) Queue (11) Smart Algorithm (11) Operating System (9) Java Basic (8) Recursive Algorithm (8) Stack (8) Eclipse (7) Scala (7) Tika (7) J2EE (6) Monitoring (6) Trie (6) Concurrency (5) Geometry Algorithm (5) Greedy Algorithm (5) Mahout (5) MySQL (5) xpost (5) C (4) Interview (4) Vi (4) regular expression (4) to-do (4) C++ (3) Chrome (3) Divide and Conquer (3) Graph Algorithm (3) Permutation (3) Powershell (3) Random (3) Segment Tree (3) UIMA (3) Union-Find (3) Video (3) Virtualization (3) Windows (3) XML (3) Advanced Data Structure (2) Android (2) Bash (2) Classic Algorithm (2) Debugging (2) Design Pattern (2) Google (2) Hadoop (2) Java Collections (2) Markov Chains (2) Probabilities (2) Shell (2) Site (2) Web Development (2) Workplace (2) angularjs (2) .Net (1) Amazon Interview (1) Android Studio (1) Array (1) Boilerpipe (1) Book Notes (1) ChromeOS (1) Chromebook (1) Codility (1) Desgin (1) Design (1) Divide and Conqure (1) GAE (1) Google Interview (1) Great Stuff (1) Hash (1) High Tech Companies (1) Improving (1) LifeTips (1) Maven (1) Network (1) Performance (1) Programming (1) Resources (1) Sampling (1) Sed (1) Smart Thinking (1) Sort (1) Spark (1) Stanford NLP (1) System Design (1) Trove (1) VIP (1) tools (1)

Popular Posts