Upgrade to Pro — share decks privately, control downloads, hide ads and more …

FenixEdu Training: Part four - New technologies...

FenixEdu Training: Part four - New technologies, Git, Maven, Collaboration

Avatar for Artur Ventura

Artur Ventura

May 15, 2014

More Decks by Artur Ventura

Other Decks in Technology

Transcript

  1. Schedule 12 15 Introduction Concepts Architecture Bennu Fenix Framework Struts

    & Renderers JSP & Renderers Faces & Spring New technologies Git & Maven Collaboration Coffee Break Coffee Break You are here Oracle: Java 8 & MySQL 18:30
  2. AngularJS • Angular allows easy binding between the model and

    the view • You write the controllers that exchange information with the server • The view is automatically updated
  3. Java SE 8 represents the single largest evolution of the

    Java language in its history. A relatively small number of features (..) combine to offer a programming model that fuses the object-oriented and functional styles. Java Language Specification, Java SE 8
  4. Java 8 Lambda expressions Method References Default Methods Repeating annotations

    Type annotations Improved type inference Method parameter reflection Streams API HashMap improvements New monitoring tools Nashorn Java Mission Control New DateTime API LongAdders Optionals
  5. Lambda Expressions for (int i = 0; i < 1000;

    i++) { FenixFramework.getTransactionManager().withTransaction(new CallableWithoutException<Void>() { @Override public Void call() { FenixFramework.getDomainRoot().getCounterSet().add(new Counter()); return null; } }); } IntStream.range(0, 1000).parallel().forEach(i -> FenixFramework.atomic(() -> { FenixFramework.getDomainRoot().getCounterSet().add(new Counter()); }));
  6. Default Methods • Interfaces can now contain default methods! •

    These allow for API evolution without breaking backwards- compatibility • They are NOT traits default boolean removeIf(Predicate<? super E> f) { Objects.requireNonNull(f); (…) return removed; }
  7. Streams API • A stream is “A sequence of elements

    supporting sequential and parallel aggregate operations” • They provide fluent views of data streams (typically from collections) • Most operations are lazy people.stream().parallel(). map(Person::getName). filter(s -> s.startsWith(“João")). count(); ! people.forEach(p -> System.out.println(p) );
  8. Optionals • Optionals are a great way to avoid using

    null to convey ‘not present’ • Integrated with lambda expressions findPerson("João").ifPresent(j -> { System.out.println("Found him: " + j); }); ! findPerson("João").orElseGet(() -> new Person(“João") );
  9. SLF4J The Simple Logging Facade for Java (SLF4J) serves as

    a simple facade or abstraction for various logging frameworks (e.g. java.util.logging, logback, log4j) allowing the end user to plug in the desired logging framework at deployment time.
  10. SLF4J ! private static final Logger logger = LoggerFactory.getLogger(FenixInitializer.class); !

    ! logger.info("Initializing Fenix”); ! logger.debug(“Got a request to URL {}”, url); ! logger.warn("Exception while closing connection", e); !
  11. SLF4J • Always use SLF4J loggers • Choose the proper

    context for your logger (Typically its enclosing type) • Be careful when choosing the log level • Always use SLF4J formatter, this avoids allocating unnecessary strings
  12. Git • Distributed Version Control System • Branching is basically

    free - Use it! • Each clone is a full copy, you can do whatever you want • A ton of amazing tools: rebase, squash, amend, commit reordering, collaboration
  13. Git Branching • A git branch is merely a pointer

    to a commit • You can freely play around with it, you can even move some commits to another point in the branch • Two ways of merging: • Fast-Forward: Simply moving the branch pointer • Creating a merge node, which points to both heads
  14. Feature Branches • Your tasks/contributions should all be done in

    a feature branch • Once you start working, create a new branch from develop and give it a proper name (e.g. feature/ spaces-refactor) • Commit all your changes to your branch • Push it to your fork
  15. Git Branching Guidelines • Always keep your branches rebased! •

    We will not accept messy history due to bad rebases/merges • Always pay attention to the version in each branch • Keep track of all your remotes • Use git fetch + git rebase at all times, or git pull --rebase
  16. Maven • “Apache Maven is a software project management and

    comprehension tool.” • Much more than a build tool • Based around the concept of project • Convention over configuration • Each project has it’s own POM file
  17. Maven Projects • Have a unique name (Artifact ID), Group

    ID (we use org.fenixedu), version and packaging. • May declare a parent project (to avoid duplicating common configuration). We provide fenixedu- project, fenix-framework-project and web-app-project. • May declare additional plugins for various tasks • Declare the project’s dependencies - No binaries in the SCM!
  18. Maven Repositories • If the dependencies are not in the

    SCM, where are they? • Maven allows multiple repository • Maven Central - Most common java libs • FenixEdu Nexus - FenixEdu binaries • Proxied third-party - Caching of third-party repos
  19. Maven Projects • From the POM, Maven knows how to

    clean, build, install and deploy a project • Fenix Framework projects run a custom plugin to implement the code generation and injection steps
  20. mvn (clean) install Builds the project, and copies it to

    your local repository. Most suited for jar projects ~/.m2/repository
  21. Maven Tips • Always check the dependency versions • NEVER

    commit POMs with SNAPSHOT dependencies • Think twice before adding any dependencies • Java 8 and Guava provide many common tools • Don’t add dependencies that you don’t need • Install the Eclipse Maven Plugin (m2e)
  22. Fenix Framework Bennu Framework Bennu Core Bennu IO Bennu Scheduler

    Bennu Portal Bennu Renderers Bennu Spring Bankai Angular Persistence Web Infrastructure Presentation Application Modules FenixEdu (IST) FenixEdu Id Cards FenixEdu Core Second Session Today
  23. It’s Open! • Anyone can contribute code to FenixEdu •

    http://github.com/FenixEdu/<project> • Use Pull Requests, Submit issues.
  24. Code • Only code correctly formatted will be accepted into

    our repositories. • We will not format the code for you. Bad formatting is a rejection reason, period. • Use the EclipseFenixCodeStyle.xml file • Works on other IDEs
  25. In the next slides… • Some words are HIGHLIGHTED. These

    are not aesthetic choices. They are mandatory for you. FenixEdu Team O nly
  26. On boarding • These rules are here to help you

    and us. • You’re not in Kansas anymore. You most likely never worked on a large group or a real life project. Your error will cost someone time. • Everyone screws up sometime. • Refer to this talk when you are doing administrative tasks (committing code, closing issues). FenixEdu Team O nly
  27. Database • You will have access to a Test database.

    • Access to this database is restricted and you can only connect to it using a SSL Tunnel. FenixEdu Team O nly
  28. Database • ssh -A -fNg -L <localport>:localhost:3306 [email protected] • mysql

    -h localhost -u<istid> --protocol=TCP -P <localport> -p<dbpass> <istid>_fenix -A FenixEdu Team O nly
  29. Database • Send us an email containing the following •

    ISTId • GitHub username • Your SSH Public Key FenixEdu Team O nly
  30. Database • You will receive an email with the dbpass,

    encrypted with your public SSH key. Instructions to decrypted it will be included. FenixEdu Team O nly
  31. Tasks • Tasks are issued to you from three ways.

    • Request Tracker • GitHub Issues • Directly FenixEdu Team O nly
  32. Request Tracker • Its the internal issue tracking system. It

    tracks everything from Academic Administrative Office requests from bugs. • RT Tickets are issued to you either by the Senior Staff or User Support Group. • After solving the ticket, give it back to who gave you. FenixEdu Team O nly
  33. Request Tracker • Do NOT Update Type to Reply To

    Requestors, EVER EVER! FenixEdu Team O nly
  34. Request Tracker • RT is a internal error management •

    External errors are managed in GitHub Issues • Internal errors SHOULD give rise to external errors when new functionalities are created or bugs are fixed FenixEdu Team O nly
  35. GitHub Issues • GitHub issues can be created by anyone.

    Anyone can solve them too. • Only Senior Staff has write permission for the main repositories (FenixEdu*, Bennu*, Sotis, etc.). Rules may vary for other repositories. • Everyone else, including you, must use pull requests to submit code. FenixEdu Team O nly
  36. GitHub Issues • When you are creating a GitHub Issue

    originating from RT, you MUST NOT include private data (ISTId, OIDs, Names, Numbers, etc.) • You can create a Issue that someone outside the FenixEdu team solves. • You can create more than one Issue for a RT ticket. Learn to divide your problem in sub-problems. FenixEdu Team O nly
  37. GitHub Issues • USE the GitHub infrastructure to close issues

    using commit messages. • https://help.github.com/articles/closing-issues-via- commit-messages • See fellow colleagues commits for more information. FenixEdu Team O nly
  38. Directly • Tasks may be given to you directly by

    the Senior Staff. • It is your responsibility to create a GitHub Issue regarding that functionality if one doesn’t exist, and close it when the functionality is done. FenixEdu Team O nly
  39. Understand & Act Design & Implement Is a bug or

    a feature? Create GitHub Issue Missing Something? GitHub Issue Issued FenixEdu Team O nly RT Ticket Assigned Close Issues Is From RT? Return RT Ticket to Issuer Request More Work Yup Yup Task given by Senior Staff Nop Nop
  40. Senior Staff • We have stuff to do. • You

    will get stuck in some parts. Not everything is easy to understand or documented. • ONLY bother us after you tried something. This will increase your knowledge of the system. “I don’t know” or “I haven’t tried” is not a good answer. FenixEdu Team O nly
  41. Senior Staff • This doesn’t mean don’t act. • If

    you are stuck, ask. • DO NOT bother Luis Cruz unless we say you so. He’s busy and has a lot more to do. FenixEdu Team O nly
  42. Documentation & Tests • You WILL write for the Bible.

    • Learn LaTeX • New functionalities, particularly new modules MUST have comprehensive tests and documentation (JavaDoc, external documentation). FenixEdu Team O nly
  43. Code • Your code will be reviewed by us before

    being integrated. • You are on a public open source project. Your code will be read by other people, including future employers. Don’t write crap you aren’t comfortable showing off. • We don’t want to read bad code. FenixEdu Team O nly
  44. Workspace • We normally use Eclipse, and Ubuntu. • We

    normally use Git on the console. • You can use whatever you want. • If you aren’t experienced with IDEs, large teams, or working on a professional environment, use what we use. If a solution exists for a problem, everyone benefits FenixEdu Team O nly
  45. Eclipse • Use Save Actions • Turn off Build Automatically.

    Doesn’t work that well. • Learn shortcuts. FenixEdu Team O nly