Showing posts with label development. Show all posts
Showing posts with label development. Show all posts

Monday, September 21, 2015

IntelliJ IDEA - Keyboard Shortcuts And More for An Ex-Eclipse User

Since, couple years ago, JetBrains made available its IntelliJ IDEA to users for free (yes, only its Community Edition), it became an interesting alternative to Eclipse IDE.  While Eclipse is a great IDE, people looking for something more (even if just a little more), may be tempted to switch to IDEA, so here's something for them from another developer tempted to switch as well.

I have bolded out the actions I tend to use all the time in Eclipse.


Basic Shortcuts:

  • C-N - open class
  • C-S-N - open any file
  • A-F7 - find all usages of the object in the workspace
  • C-Q - quick doco (info) about the object under cursor
  • C-click - go to definition/implementation
  • C-F12 - show quick outline of the class
  • C-Space - auto complete
  • C-S-Space - power auto complete (Tan and Enter - both select, but differently)
  • A-Insert - code generate
  • C-/ - comments with //
  • C-S-/ - comments with /*...*/
  • C-D - duplicates the selection
  • C-S-BckSpc - move back in change-history locations
  • C-S-F7 - highlight an identifier; F3 and S-F3 move to next/prev usage; Esc - de-highlight
  • Code | Optimize Imports - from menu
  • C-E - recent files list
  • call tree of the current method: C-A-H
  • locate the current file in the project tree: there is an icon in the project viewer
  • move selected statements up or down the file: C-S-up and down
  • go to declaration of the object: C-B 
  • go back in the browsing history (as opposed to change history):
    C-A-left and right or C-[
  • synchronize a file or a project against the SVN repo: see Version Control tool
Legend: C means Control, S - Shift and A - Alt

Advanced Shortcuts:

  • S-F6 - refactor: rename
  • Esc - in a tool window - moves focus to editor (S-Esc - also hides the tool window)
  • F12 - opposite to Esc
  • C-A-T - surround it
  • C-W - extend the selection
  • C-A-V - refactor: extract variable
  • Tab - live templates (np. itar Tab)
  • Local History | Show History - from file or directory shows and lets  revert to any version all changes in this file or directory

Create a New Project from Sources in IntelliJ: 

  • Open from sources or from SVN/GIT
  • Open Project Structure dialog (Ctrl+Shift+Alt+S) and specify which are source folders using the Module item from the left-hand panel

Friday, December 16, 2011

Java Project Layout - Best Practices

Simple Project
  • project-name
    • trunk
      • src...
      • pom.xml
    • branches
      • branch-abc
        • src...
        • pom.xml
    • tags...

 Multi-Module Project
  • project-name 
    • project-name-parent
      • pom.xml - defines all modules that are part of the project
    • module 1 
      • trunk
        • src...
        • pom.xml - points to the parent pom.xml
      • branches
      • tags
    • module 2
      • trunk
        • src...
        • pom.xml - points to the parent pom.xml
      • branches
      • tags
    • module ...
 The key point is that the parent folder doesn't define the parent project, but is just a container for the parent and the children-modules.

Advantages:
  • Nicely groups the modules under one folder.
  • Allows to build the whole project by calling "mvn clean install" from parent's folder.
  • Keeps the SVN (and/or Git) operations simple, unlike the layout where the project-name-parent is the parent folder.

    Wednesday, February 3, 2010

    Persistence Frameworks, ORMs

    The big three, I consider mainstream (from Java perspective):
    • Hibernate
    • JPA
    • JDO
     I have sorted them in the market share order, but there are some interesting facts that make all three important:
    • Hibernate is definitely the strongest, most popular ORM framework for Java and .Net, but it's not a standard per se.
    • JPA is a standard and it's fully supported by HIbernate, so choosing it gives you some advantages over Hibernate. Its design was based on Hibernate and JDO.
    • You can use Hibernate and restrict yourself to the JPA-only, which gives you a portability to another JPA-type framework, if you so choose in future.
    • JDO, although the oldest one, is the preferred persistence mechanism for Google Application Engine, the Java application hosting service of Google (although, you can also use JPA with it).
    Which framework to choose? Your choice.  Need more help choosing? Try this article.

    Monday, September 7, 2009

    Parsing a Text on Android Phone

    Introduction
    I have a wiki markup text that I need to parse. My first version, which I use in DroidWiki application for Android, is a wiki custom parsing. I wrote my own parsing, because I haven't found a parsing code on the internet that was light enough to be used on Android phone. That code does a regular expression matching for each wiki tag. So, every line is matched at least Recently, I decided to try my hand at more fancy parsing: just parse into a sequence of tokens. Below, are the results of my research on this topic.

    Using One-Character-At-A-Time Parsing
    One way to solve the problem is to use a one-pass parsing, having the Java code to look at each character (just once) and isolate the tokens this way. Using the character iterator goes like this:
    StringCharacterIterator iter = new StringCharacterIterator(markup);

    for( char c = iter.first(); c != CharacterIterator.DONE; c = iter.next() ) {
    // process the char: is it one of the characters that starts any of the syntax tokens?
    }

    This could be fast, but the code would be complicated. I decided for a different approach.

    Using Interpreter Design Pattern

    The idea:
    1. Parse the text and convert it to a sequence of basic tokens:
      • every continuous piece of a regular text is a token
      • every sequence of syntax is a token (for example, the char less-than if parsing HTML text would be a simgle token by itself)
    2. Process the list of these basic tokens and aggregate them into complete syntactical elements (for example, every complete HTML tag would be a single token).
    If you want, create
    • a SimpleToken class for item 1 above,
    • a base Token class and specialize it for more significant/complex syntactical elements for item 2 above