Sunday, October 9, 2016

My Devoxx Adventure, Made in Morocco.

                 Back to 2013, I was searching on the internet, so I spot a link leading to a meetup it was about Java, but I was a .Net developer then, the organizer was a group named MoroccoJUG, the subject was “Java Secure Coding sessions and Hands On Labs “, organized by Mr. Azzeddine Ramrami an information security professional working in Paris, so I reserved my seat in this meetup, and I noted it in my Google Calendar as usual. At the day of the meeting, I saw a lot of people who share the same passion the same interest (Is this real?) but they didn't have the same face!!!!! I was really surprised that behind this organization was very youth team, and I remember Mr. Badr EL HOUARY, who has invited me to the breakfast, YES A DELICIOUS BREAKFAST, I was not at home but in a real meetup!!!!

Azzeddine Ramrami at 'Java Secure Coding sessions and Hands On Labs' © Morocco JUG

And Yes, after that meeting I decided to explore Java ecosystem, and after some months, I became mainly a java developer, honestly I found my passion in this language, which is very flexible and open to any other technology, But beside Java, I was impressed and surprised that we have such a group managed by community for community, afterward I assisted every group's meeting until now, and I was lucky that I assisted JMaghreb 2014 as my first conference specialized in development.

                                                    Kaynote at JMaghreb  © Devoxx Morocco
          
          In 2015, JMaghreb became a part of Devoxx family and changed his name to Devoxx Morocco, so the first conference was in the last November for three awesome days. Speakers and attendees were from all over the world, you can easily have a casual conversation with the founders of the Open Source  technologies, like Juergen Hoeller the co-founder of Spring or  Markus Eisele the founder of JavaLand author of the book “Modern Java EE Design Patterns”. The special thing in Devoxx Morocco is, you can be a speaker for the next edition as well, who knows? You should just stay tuned and wait for cfp (Call of papers) period, so you can send your proposal for validation by the team.

               Keynote at Devoxx 2015 © Devoxx Morocco

                 In the 2016 edition, Devoxx Morocco will have a new look and a new air, if you want to get the last news you can subscribe on the Twitter, Facebook, Google+ or Youtube stream, and if you would like to be a part of this experience you can sponsor the event, or just send (at info@devoxx.ma) your propositions and what you would like to see for the next editions.
Are you passionate and interested in the new development technologies? You‘ll find an amazing community waiting for you in Devoxx, you should just reserve your ticket in Devoxx.ma and prepare for the journey!!

Ah! Don’t forget to bring your laptop, you will create a great stuff!

Wednesday, September 3, 2014

Get Schema from your Collection on MongoDB

     

      
        As I'm preparing a M101J: MongoDB for Java Developers, and now it's my fifth week within, however I've encountered a problem during the assignment of the week, and it was about how to get the keys (Fields) of a collection (of course if it has one schema for all his documents, and not different one), because even if you perform the function findOne(), you can't find out what's exactly the schema and especially if the retrieved document has a bunch of data (Like the one that is delivered for the assignment) and it'll be hard to distinct the keys from the data....Just I want to notice that mongoDB use JSON format to store data.
So one of the solution is using JavaScript in mongo shell to get your keys out, and you should execute the following code (don't forget to change the collection name !!) :

> myKeys = db.myCollection.findOne();
> for (var key in myKeys) {print(key);}


But if you want also know what's the type of each key (field), your can replace the second command by the following 

> for (var key in myKeys) {print(key + " ==> " + myKeys[key]);}

    That's all, just remember in this solution we suppose that the collection has unique schema because if not you will not get a relevant result!

Monday, August 18, 2014

Shopizer the First Step

As I love programming, I devote myself to be a volunteer programmer in shopizer project, it's an open source project that create an e-commerce application using Java ecosystem (With mainly Spring MVCSpring CoreSpring SecurityHibernateJBoss InfinispanElasticsearch and JBoss Infinispan).

However as the first step to be a part of the development team you should be able build the application locally and run it successfully, but I encounter a problem in this stage and maven wasn't able to deliver the war file from the core project "sm-core" which is necessary to run the main one "sm-shop",  in addition it displays an error message :

--> [INFO] BUILD FAILURE

My desktop while building Shopizer!

(Using My Maven version is : 3.2.2 and my Java : 1.8 Oracle version.)

...Yes that's was a mess especially by attempting a couple of actions to make thing in its place, but without a tangible result,
...by the way and by analyzing the file which was created from the mvn command using pipe in my Ubuntu, I realize that there's a warning indicates that the supported source version for java is 1.6 for some sources but I'm using 1.8, that was not clear as it's  thought but it was evident for java daily developer that maven talk about Java version and not about something else.

So I switched to the oracle JDK 1.6, hence  the building successfully passed and I was able to create my war file of the core project, and  by following the remaining instructions I've run the shopizer app without any issue, which mark my successful beginning in the dev team......Yoppi

-->[INFO] BUILD SUCCESS


What I've learnt from this issue??
I learned that before building a project or running it I should read carefully the related instructions and I should be able to use any accessible debug tool effectively (Use Pipe technique to generate a log file, Use different options and let your command to be more verbose...   ) because it's not the matter of what you know but the matter is how you USE what you know.....



Wednesday, August 6, 2014

The Final keyword for Variable



I always heard from other java developers that a Final variable is a constant that will never “change” its value, like:
Final int pi= 3,14 ;

...Then if we try to change the [pi]  value we will get a compiler error :
Pi=0 // compiler error -> "The final local variable i cannot be 
        assigned. It must be blank and not using a  compound 
        assignment"

That’s true  for primitive type in java but what’s about the variable that point to a reference,  does the object will really never change?

Let’s see the definition from the source :
“Once a final variable has been assigned, it always contains the same value. If a final variable holds a reference to an object, then the state of the object may be changed by operations on the object, but the variable will always refer to the same object. »

So as text says, if the variable HOLDS a reference to an object, the behavior will not be as like as a primitive type, …..Hmm…that’s interesting…let’s do some practicing to unveil this concept. 

Note : Don't waste your time by copy and paste the code, you can download the whole project from the link at the end of the article (in the very last sentence!!!!).

We create [Person] class as follow:

public class Person {
  String lastName;
  String firstName;
  int age;
 
  public Person(String lastName, String firstName, int age)
  {
     this.lastName = lastName;
     this.firstName = firstName;
     this.age = age;
  }
}
In the source file you'll find more code in the [Person] class(Getters, Setters...)

The main class:
public class MainApp {

 public static void main(String[] args)
  {
     final Person p1;
     final Person p2 = new Person("Ahmed", "SAMIR",20);
     p1 = new Person("Omar", "BEHLOUL",38);

     p1.age = 26;                 // ok no error
     p2.firstName = p1.firstName; // coz we're changing the fields and not the reference

     // p1 = p2; // compiler error --> "The final local variable p1 may already have been assigned"
                 // p1 can't refer another object (p2)
  }
}

….So as we can see the final keyword bring a tricky behavior when the variable points to reference : 
  • You can’t refer it to another object after the first assignment.
  • The member/fields of the final variable can be freely changed without any restriction.
                    ...may be one day Java can close this back door of final keyword with variable!


However this attitude of final variable can be a benefit for your program but can be against you too , and it mainly depends on your designing of the application...so be careful!!

Hey...one minute, just to remember you that final keyword exists also for:
  • Class to stop inheritance. 
  • Method to stop overridden.
that's all......

You can download the source code from here...Good testing!


Friday, July 11, 2014

No stupid Human being

Photo of  Steve Jobs
"When you grow up you tend to get told that the world is the way it is and you're life is just to live your life inside the world. Try not to bash into the walls too much. Try to have a nice family life, have fun, save a little money. That's a very limited life. Life can be much broader once you discover one simple fact: Everything around you that you call life was made up by people that were no smarter than you. And you can change it, you can influence it… Once you learn that, you'll never be the same again."   

Yes that's right ....no one is stupid in this universe....the difference between smart people and "stupid" one is that the first know that they've the ability to use up there mind in a better way but the other don't have that knowledge!!!!

Thursday, July 3, 2014

Maven Life Cycle ...basic explanation:

      I've looked for a while to reach a simple overview of the project management and comprehension tool Maven and especially the life cycle process.

Firts of all some history :
      Maven was originally designed to simplify building processes in Jakarta Turbine project. There were several projects and each project contained slightly different ANT build files.
Apache group then developed Maven which can build multiple projects together, publish projects information, deploy projects, share JARs across several projects and help in collaboration of teams.

The point :

As we talk about  Maven Life Cycle, so here is basic definition of it :
       Each of these build lifecycles are defined by a different list of build phases, wherein a build phase represents a stage in the lifecycle.
For example, the default lifecycle has the following build phases :
  • validate - validate the project is correct and all necessary information is available
  • compile - compile the source code of the project
  • test - test the compiled source code using a suitable unit testing framework. These tests should not
    require the code be packaged or deployed
  • package - take the compiled code and package it in its distributable format, such as a JAR.
  • integration-test - process and deploy the package if necessary into an environment where integration tests
    can be run
  • verify - run any checks to verify the package is valid and meets quality criteria
  • install - install the package into the local repository, for use as a dependency in other projects locally
  • deploy - done in an integration or release environment, copies the final package to the remote repository
    for sharing with other developers and projects.
These build phases (plus the other build phases not shown here) and executed sequentially to complete the default lifecycle. Given the build phases above, this means that when the default lifecycle is used, Maven will first validate the project, then will try to compile the sources, run those against the tests, packages the binaries (i.e jar), run integration tests against that package, verifies the packaging, install the verifed package to the local repository, then depoy the installed package in a specified environment.
To do all those, you only need to call the last build phase to be executed, in this case, deploy :

--> mvn deploy

.....I think is a simple way to undertand the Maven lifecycle concept.

References : Google...yes always it's Google that bring us the informations...