Upload
strongback-consulting
View
396
Download
0
Embed Size (px)
Citation preview
© 2014 IBM Corporation
DAX-5162C-ing is Believing: Being Smart about C/C++ Development on AIX and LinuxKenny Smith, Strongback Consulting
About Us: Strongback Consulting
• IBM Advanced Business Partner• Rational, WebSphere, ICS SVP certified• Strongly focused on DevOps, Enterprise Modernization, and application infrastructure• Key Industries Served: Finance, Insurance, Travel, Logistics, Healthcare, Manufacturing,
Government• Rational Design Partner for HATS and other Rational enterprise modernization
technologies
Discover us at:http://www.strongback.us
Subscribe to us athttp://blog.strongbackconsulting.com
Socialize with us on Facebook & LinkedIn http://www.facebook.com/StrongbackConsulting
http://www.linkedin.com/company/290754
3
Talking Points
• Editors• Content Assist & Templates• Refactoring• Static Code Analysis• Performance Advisor
4
In the beginning….
5
Then came telnet
• Edit directly on the target computer• English based language construction
6
Next came vi… and then vim
• Colorized parsing of code, regex search/replace• ..but this is where most people stopped!
7
Why do I need a rich development editor?
• Productivity! [proh-duhk-tiv-i-tee]• Its about the economics!• The rate at which goods and services having exchange
value are brought forth or produced – :Productivity increased dramatically last year.
• Why do you use a word processor instead of a type writer?
8
Complexities of C/C++
• C makes it easy to shoot yourself in the foot. C++ makes it harder, but when you do, you blow away your whole leg! — Bjarne Stroustrup
• Pointers• Memory arithmetic• Memory leaks (see above)• Compiler differences – variability depending upon the processor• Syntax – language elements not found in other languages• Debugging
The Editors:LPEX, C/C++, Remote
9
10
The LPEX Editor
• Can act like the standard editor of any system• vi/emacs for *Nix systems• ispf for mainframe• seu for IBM I
• Change appearance to make it look like telnet
The General C/C++ Editor
• Multiple ways to edit C/C++ source• C-C++ editor - Acts more like typical
Eclipse language editors (such as Java)
• LPEX Editor – can emulate vi editor• Use context menu, Open With to open
with a specific editor• Remote C/C++ specifically used in
AIX/Linux projects
Icons used for C/C++
• Icons found in• Project Explorer• Call Hierarchy• Type Hierarchy• Outline View• Make targets view• Navigator View
13
Syntax Highlighting
• Comments• Strings• Reserved words• values, variables Current cursor
row has blue background
14
Method indicators
• Margin is highlighted in blue indicating the beginning and ending of the current method
method indicator
Cursor position
15
Code Folding
• Comments, methods & classes can be collapsed or folded for ease of reading
• Click on the + to expand• Click on the – to collapse
Indicates additional code inside the collapsed area
16
Hover
• Place your cursor over a variable or method• Displays a window showing the declaration
Hover mouse over the convert method
Window pops up in the editor showing
the declaration.
17
Errors / Warnings
• Margin area indicators to show errors or warnings
• Hover the cursor over to show more information
• Warnings also underlined in yellow squiggles
Column location of error
Hover over marker
18
Mark occurrences
• Put cursor on a variable name
• Additional occurrences marked with a gray background
• Toggle on/off with the task bar icon
19
Show whitespace characters
• Use menu bar to show grey symbols representing whitespace characters
• Space, tab, carriage return, new line, etc.
20
Code formatting
• Shift left / right• Correct Indentation• Format
• auto formats the entire source• properly indents throughout
21
Format Source (CNTL+SHIFT+F)
Before After
22
Commenting code
• Highlight multiple rows• Click CTRL+ / to comment• Click CTRL + / to uncomment• For /* style block commenting, use
CTRL+SHIFT+/
23
Open Declaration
• From context menu, or F3: opens declared method location
• If in another file (or header), the file must be on the search path
• Also depends on the type of project you are using– MVS Subproject, z/Unix Subproject, C/C++ project, zFolder, etc.
24
Quick Outline
• Right Click → Quick Outline• Shows a searchable outline of the
source member• Type in the text field to search
methods and types
Enter search text here
Filtered Results
25
Call Hierarchy
• Right Click → Open Call Hierarchy• shows the loaded callers and callees for a selected C/C++
function
Toggle between caller
and callee
Hide contants, enums, and
variables
Show history of call hierarchy
26
Find Dialog
• CTRL + F to bring up dialog
• Can search case sensitive, forward, backward, on all code, or just that selected.
• Regular expressions• Content assist
available to help build a search query
27
Customizing the Editor
28
CNTL+SHIFT+L
• Shows ALL keyboard shortcuts available• one keyboard shortcut to rule them all
Content Assist &Templates
29
Content Assist
30
• Allows you to provide context sensitive content completion upon user request
• CTRL+Space again to cycle through parser or template proposals
• Clicking or pressing Enter on a selected line in the list inserts the selection into the editor.
Configure the behavior of the content assist in the C/C++ → Editor → Code Assist preference page.
31
Content Assist Sources• In the C/C++ editor press Ctrl + Space on code to complete. This
opens a list of available code completions. • Use the mouse or the keyboard (Up Arrow, Down Arrow, Page Up, Page
Down, Home, End, Enter) to navigate and select lines in the list.• Existing methods, properties, fields, etc.• Language constructs• Code templates
What are Templates?
• Simply put, little pieces of code with defined placeholders• Work slightly differently than snippets• Place holders are called variables
• Syntax is ${variable_name}• Eclipse based – many languages supported• Java, ANT, COBOL, PL/I, JavaScript, HTML, XML, etc.
• Can be imported & exported• Can vary be easy or difficult to setup • Will save you HOURS upon HOURS of hand coding!
Creating Templates Continued
• Insert Variable – inserts a given variable• Variable is described in the yellow box to the right of its name
34
Syntax Check
• Editor parsed syntax checking
Refactoring
35
Refactoring
36
Refactoring: make system-wide code changes without affecting the behavior of the program.
Refactoring commands are available from the context menus of several views (e.g. Project Explorer, Outline) and editors. Many "apparently simple" commands, such as Move and Rename, are actually refactoring operations, since moving and renaming elements often require changes in dependent files.
• Extract a function, constant or local variable• Rename a method, variable or class• Hide a method signature
Operations can be previewed for all of the changes resulting from a refactoring action before you choose to carry them out.
37
Extract Constant
• Improve performance, and avoid duplicate strings
38
Renaming
• Easily rename a variable throughout your code• More accurate than find/replace
– i.e. try to find and replace a single character variable!
Source Actions
39
Use the Source menu to perform many actions to modify, remove or generate code automatically.
• Toggle a line or block as a comment; on or off.• Format entire source files or fragments.• Correct Indentation• Implement getters & setters• Sort lines
The Source menu can be accessed from many context views such as in the C/C++ editor.
Software Analyzer
40
41
Static Code Analysis
• Software analyzer built into the product• Static code analysis can find common coding errors• Can create scan configurations and check against multiple rules
42
Software Analyzer Results
• Categorized results can be exported into XML• could import into RTC as work items for remediation
• Severity and categories tell you which things to work on first
43
Tuning with Performance Advisor
• Collects data via tprof/procstack (AIX), or oProfile (linux)
44
Summary
• Why we have tools – PRODUCTIVITY!• Editor improvements over vi• Refactoring tools• Content Assist, Templating• Static Code Analysis• Performance Advisor
• What we did not cover: Debugging• This alone is worthy of this tool in your toolbox
45
References
• Performance tuning C/C++ applications with Performance Advisor in RDAL
Questions?
46
Thank YouDiscover us at:http://www.strongback.us
Socialize with us on Facebook & LinkedIn http://www.facebook.com/StrongbackConsulting
http://www.linkedin.com/company/290754
Subscribe to us athttp://blog.strongbackconsulting.com