RSS

Category Archives: Technology

Enterprise Technologies

Into the Wild

Entry 10, Day 20

Time to talk a little environment. Go green, plant a tree, that kind of stuff. Kidding. We are going to talk about the server and the data source for the application. First, what is actually a server?

Server in general is something (hardware + software) that provides responses for requests across the network (or even locally). We are mainly interested in web servers, so we have a http request and http response. This doesn’t actually narrow down to www. They are WebServices carried over http via SOAP. You know, machine talking to another machine, skipping the unreliable protein-based components. Since I’m a programmer, not a sysadmin, by the term server I will understand the software part.

There are basically 3 tiers of server, we would be interested in:

HTTP Server. This is basically just to serve static resources, including client side scripting languages. You can build quite a big piece of an application in GWT, and as long as it does not require any server side dynamic behaviour (say database access), you are good. But who doesn’t require database access those times? The unbeatable king of http servers is the Apache HTTP server. The piece of software that gave name to the entire organisation later. Before Java settled in the web, we would just take Perl or PHP, put it somewhere around Apache, lay hands on database, or whatever is needed and be happy. But now we have…

Web Container. It is more than http server, since it implements a tiny but important part of Java Enterprise Edition api. Namely Servlet and JSP. Those seem to be a bit outdated technologies, but they are a basis for every new and fancy stuff in Java web world. For example, Spring is actually a big servlet underneath. Again, there is a clear leader in this field, Apache Tomcat. But what, if you need more?

Application Server. The monstrosity that implements entire JEE specification. So, besides what web container offers, we have JSF, persistence, transactions, messaging, batch api and other stuff, but perhaps most notably: the Enterprise Java Beans. There quite a few application servers out in the field. I’ve worked with Weblogic and Glassfish. If you don’t like Oracle, there is also JBoss (it is called WildFly now, as I’ve just learned). Or Apache Geronimo for anarchists.

So, what do I actually need? Since I’m going to use Spring, and Spring has many features that replaces JEE standard (Actually many apis in modern JEE were inspired by Spring.), I’m not going to need full application server. Web Container is enough for Spring, so it should be enough for me. Since picking up a popular server simplifies hosting and development in general (lots of people have the same problem as you) I’ll go with Tomcat 8.0.9. If there would be a need for an application server in the future, we are going to have a migration. Shouldn’t be tough, should it?

And what about database? I have serious time issues recently, so in order not to keep this post too long in the draft state, we will talk this through in the next episode. Stay tuned.

Project-wise, I’ve set up Tomcat, created a project draft, installed MySQL and did some smoke test displaying stuff from the database via simple servlet. Nothing fancy, just hellowording. Now I’m looking for some nice MySQL client besides command line :) Any suggestions?

How-To-Train-Your-Dragon-2-Wallpapers-23

 
1 Comment

Posted by on August 21, 2014 in BookSentry, Technology

 

Tags: , , ,

Tools of the Trade

Entry 8, Day 14

Over ten years ago I have written my home page in PHP. Nothing really big, but it had a user system, administration, news, comments, file downloads, image gallery with some search/paging options, rating etc. I think there was around 100 – 200kB of code. I did this almost entirely in Windows notepad, only at the end switching to some kind of editor with html syntax highlighting. But things can be done easier.

First, you need an integrated development environment. I will use Eclipse Luna, released not even two months ago. I’m using Eclipse for over five years and still learning new stuff on a weekly basis. Alternatives are: InteliJ, NetBeans or something else.

When dealing with web application, there are several useful tools on the browser side. First, the browser itself and it’s integrated development tools, at you disposal when dealing with html, css and client side scripting problems. My favourite is Firefox. When browser tools are not enough, I recommend Firebug, excellent for debugging JavaScript if you are in a pitiful situation that you need to do that (you shouldn’t if you use GWT, but…). In order to work with GWT efficiently, you need DevMode, it will compile your Java code to JavaScipt on the fly and allow to see changes almost instantly, Yo will need a plugin for Eclipse and a plugin for your browser to accomplish this. Unfortunately since Firefox 27, support for DevMode has ended (wtf dudes?), so either stay at 26 or try some workaround.

Compiling, putting into jars, bundling etc. – Maven is your friend here. If you are old school, get back to Ant.

When you write something and it works, or even before it does, you are in need of some version control system. As of my information, Git recently took over SVN in terms of popularity. Also, I’ve worked long enough under SVN, so lets try something different. Git it is.

Having a build automation and version control, you can put them together in continuous integration tool. It will take the code each time someone does commit and each night, build stuff and scream at you if you blew something. Jenkins is probably the best choice here. You may know it’s older version, Hudson, which killed itself after being taken over by Oracle.

There are plenty of additions to CI, most of them also available as IDE plugins.

Most notably, test automations frameworks. Unit tests for low level stuff (go JUnit with Mockito) and web/GUI tests for high level/integration (Selenium being a popular choice).

It is good to have some kind of static code analysis. Teach it a set of rules, and it will guard your code from deteriorating at low level and perhaps find some bugs for you, that might have slipped through runtime test suite. Check out FindBugs. For higher level of analysis I recommend SonarQube (known simply as Sonar in the old days). It will also give you a bunch of numbers about your codebase, if you like numbers. I like numbers.

There are plenty other useful stuff for your CI, e.g. some dashboard view, excellent to de displayed somewhere high on the wall, to tell others that your build is never broken. Or to tell you that it actually is now and it would be nice to fix it. You may also want to hear this.

Besides development, you want to keep track of what is to be done, ongoing and done. So basically a product and a sprint backlog. Until now I’ve used mostly simple Excel and physical pin board, I need to do some research here and get back to it.

Also there are systems for issues tracking (fancy term for bugs), which may be used instead of, or with backlogs to help you control your chaos. (Hi Kate ;))

Pedal_control

 
2 Comments

Posted by on August 15, 2014 in BookSentry, Technology

 

Tags:

Here be dragons

Entry 7, Day 11

It seems that I’m more of a writer than a coder in this little endeavour. Well, old habits die hard, I wrote quite a lot of stuff several years ago, although not really technical. Anyway, this is good. Before you sit to code in the new projects, there are some stuff, you need to discuss with other devs, the Product Owner, Stakeholders/Clients, right? (Yes, devs can talk to Stakeholders directly, even though the PO is their default world interface. It can be very beneficial to the project). So now, let’s wander into the unknown lands of dragons. The enterprise (and less enterprise) technologies. There will be a lot of links.

Usually, there is a number of so called “technologies”, you will want to use. Theoretically, you can write an application using almost pure Java on top of application server (or what the hell, even without the server, just play with sockets manually), but it is impractical to say the least.

Under normal circumstances, the technology choice depends on what you want to achieve, what are the skills in the team at your disposals or other external factors like deals with big nasty software corporations. Since I’m my own client, I’m free to do what I please. I will go for some healthy mix of things that are suitable, fun, that I want to learn, and that I already know, and want to know better. Using only unknown technologies might be more beneficial from the learning point of view, but being struck at every aspect of the application might not be funny (not that I’m a pessimist, but I’ve seen stuff…). So I need some fields, where I know I can go fast to repair my ego if needed.

So, the main technology I will use is Java 8 language, as I’ve mentioned in the previous post.

Of course, since we are talking web application, the backbone of everything is HTML, this is what the user receives at the end.

There must be some kind of presentation technology (unless you are writing some purely backend EDI system or something similar). If you are truly old school, you can go with JSP pages. A bit more modern approach would be JSF or Velocity. There are plenty fish in the sea.

Client likes the application to be responsive. So instead of reloading the entire page, you can do things in the browser, instead of on the server. We can go with JavaScript, Dart, or my favourite: GWT. Actually GWT will do the job with both static and dynamic web content, and it is a Java compiled to JavaScript. I’m a big fan.

Then there is (usually) the framework that simplifies things (or complicates, depending on the framework and usage). Spring is the choice here, since it’s tremendous popularity in recent times. I’ve used it quite a bit, but there is still much to learn for me.

There is an object-relational mapping framework, Hibernate being popular choice.

Those are the core technologies. There will probably be many more, but we are not doing Big Design Up Front, remember? I will add and comment on new stuff as needed.

By the way, I think the word technology is sometimes an overkill when it comes to software. Nuclear bomb is a technology. Internal combustion engine is a technology. Microprocessor is a technology. Although Wikipedia says that technology is “collection of tools, including machinery, modifications, arrangements and procedures used by humans”, it seems to me that a piece of software written by a guy over several evenings while drinking beer shouldn’t be called that. Not that I don’t respect contribution to mankind well being, but there is a matter of scale. Probably “library” is sometimes a better word than “technology”.

dragons

 

 
Leave a comment

Posted by on August 12, 2014 in BookSentry, Technology

 

Tags: , , ,

The Peak of the Mountain

Entry 6, Day 10

The technology stack… We’ve talked a bit about tiered application composition, now let’s take a broader look. Software is basically composed of layers. That simplifies things. You have an operating system using hardware directly. Then, there is the Java runtime providing abstraction between Java bytecode and actual program execution. Then, if we are in the JEE realm, we have a server.

The kind of server depends on you needs. If you like EJBs, you need an application server (Weblogic, Glassfish or whatever). If you prefersomething lighter, you can go with web container (like Tomcat). Finally to help you serve static content like Java Script (which is static in terms of being executed on client machine, not ours), there are http servers like Apache. You can combine all of them – use application for EJB layer, web container for web layer and http for static. There might be, of course, many more servers in the application ecosystem, namely proxies, firewalls, load balancers (or it can be dedicated hardware, and usually is), but this is more of the infrastructure domain, not application.

Then there is some kind of framework providing abstraction over JEE api or just complementing it. Think Spring.

And, at the peek of the mountain, there is Java language. The language shapes architecture of your system, ties things together and allows you to play with stuff. I’ll go with Java 8 because well… cutting edge, you recall, do you?

Actually Java 8 is quite cool. Everyone says that’s because finally we have lambda expressions, but there is more. There is, for example, internal iteration.

Internal iteration, instead of imperatively iterate over collection, allows you to declare iteration and let the runtime do the rest. Why it is important, you may ask? Because if you iterate imperatively you do that either in sequential way, or you have to play with threads, think about number of available cores and do other tedious and error prone stuff. If you let the runtime iterate, on the other hand, it may perform e.g. a new forEach operation concurrently, using all available cores, and this is transparent for you. It makes things simple and fast.  Also, a new Stram api allow you to perform map, filter, reduce, and other operations with performance improved by doing what really must be done lazily. I haven’t yet explored all new features of Java 8, but things look promising.

<scary JVM internal stuff>

By the way, lambdas aren’t just syntactic sugar for inner classes as many people think. In fact, lambdas implementation in virtual machine uses additional layer of abstraction. Lambda is actually a recipe, not an imperative piece of bytecode. It’s true bytecode is generated on runtime, not compile time, using fifth invocation mode, invokedynamic, introduced in Java SE7 to support dynamic JVM languages (Groovy, Jython etc.). Lambda call site is created using so called “language logic” or “bootstrap method” that was to be provided by specific dynamic JVM language to help dispatch calls. In Java language lambdas execution, such logic is called Lambda Metafactory.

As a result of several nifty VM tricks, lambdas are much faster than inner classes, especially on multicore systems, and have a potential to be even faster in further versions of Java. If you are into this stuff, check out a cool presentation by Brian Goetz, the Java language architect.

</scary JVM internal stuff>

So, I’m going to use Java 8. And few other runtime technologies, which I will discuss in the next post.

top of the mountain

 
1 Comment

Posted by on August 11, 2014 in BookSentry, Technology

 

Tags:

The Matrix

Entry 5, Day 8

The first matrix I designed was quite naturally perfect. It was a work of art. Flawless. Sublime. A triumph only equaled by its monumental failure.

– The Architect

Software Architecture is the high level structure of a software system. Now I’m smart, I have Wikipedia.

Sometimes, if you ask a developer what is the architecture of the system he is working on, he would say something like, “Well, we have a JSP view, we use EJB to figure things out, Hibernate to persist and everything sits on top of Weblogic server”. Actually, this is not an architecture description, this is a list of technologies used to create the system (or, if you need a fancy term: the technology stack). Of course, there is a slight hint, that we are dealing with a client – server application with at least three layers.

Architecture might be client – server, peer to peer, event driven, rule based, plug-in based or other. Or the combination of them.

As I said before, I’m aiming for agile, emergent design. It does not imply, that I don’t have some kind of vision of what I want to write. I will probably go with client – server, multi tier application. What does this mean? We know more or less, what is 3 – tier architecture: we have a Presentation layer, Business Logic layer and Data layer. So where is the fourth and fifth or any further layers? Well, you may divide those layers further. Let’s take a look.

Presentation is well… presentation. But if you go beyond simple CRUD, it might turn out, that you need some kind of logic just for managing presentation (fancy drag n drop and dynamic stuff support for example), not really business logic layer, but layer separate from static HTML inputs. So, you may split this into two.

Business Logic might have controllers, which glues together front end and back end. And then, they might have EJBs or Spring Services, which performs actual computations or choices having data and given user input. Or other input for that matter, say JMS messages or WebServices calls from foreign systems. Also, you may split service in as many layers as you need depending on the case. Some systems might be very sophisticated, and saying that there is just one business logic layer would not be an understatement.

Data layer may consists of Data Access Objects, which gives you data in the form of cute little Java objects magically drawn from the database. Then there is the magical Object Relational Mapping Framework at work, preparing and running queries in SQL native to the database, transparently for the user. Database is the, more or less, final layer, and besides table definition it may consists of triggers, scheduled jobs (for partitioned tables periodic cleanup, for example) and some other nasty things. Perhaps there are also other layers in the database department, but well… I’m more like in the Java department, so I won’t dig deep here.

Some developers shun the idea of doing any logic outside of Java code (I’m not talking about external libraries, but I will later). I was such developer once. But I’ve figured out, that some things may be better done outside of Java, even though I cannot put a breakpoint there. I’d love to think about them as Java minions who do some magic yet inferior things, but as long as they do it well, I have no objections. Otherwise I will have to frown my eyebrows, get out of coziness of my beloved Eclipse and step in to figure out why SQL or ant script is behaving badly.

 

vsbigone

 

 
Leave a comment

Posted by on August 9, 2014 in BookSentry, Clean Code, Technology

 

Tags: , , ,