Creating design document from existing java code - sdlc

I have existing java code and need to create Design Document based on that.
For starter even if I could get all functions with input / output parameters that will help in overall proces.
Note: There is not commeted documentation on any procedures, function or classes.
Last but not least. Let me know for any good tool which will reduce time required for this phase. As currently we write every flow and related stuffs.

What you want is just too much. Quoting Linus Torvalds: “Good code is its own best documentation.”. Anyway, I digress.
You might want to look into UML tools which generate class/sequence diagrams from the code. There are many of them but only a handful support reverse engineering (into and from the class diagram), and even fewer subset support the same to/from sequence diagram. I only know MagicDraw could do this, but I am biased as I used to work for the manufacturer of this tool so do your shopping around first.

Use java docs: http://www.oracle.com/technetwork/java/javase/documentation/index-137868.html
or Introspection: http://docs.oracle.com/javase/tutorial/reflect/class/classMembers.html

Related

Visual statechart editor for non-programmers, with limited conditions, events and actions

I'm looking for some visual statechart-editor, for my customer. I'm building for him server application, and he needs tool to build statecarts and upload them to the servers. Ofcourse, the tool needs to have the capability to export to some readable format (such as SCXML), so I could build a reader for it.
I saw some tools, like fsm-editor. But they can't be good for me, because I want to limit my customer to set of specific set of parametrized-conditions, parametrized-events and parametrized-actions.
For example, I'll define:
conditions: coIsDoorOpen, coIsThereNAppelsOnTheTree(n as uint[0..200]), ...
events: evLightOn, evLightOff, evTimeout(ms as uint[1..10,000]), ...
actions: acSetAlarmOn, acCloseWindowN(n as uint[1..10]), ...
and my customer could build some dozens statecharts with those explicit predefined attributes (conds, events & actions), and upload the export of them to the approperiate places.
There is no need to be strict to one statechart-standard or to another. But I need support on this things:
parametrized conditions/events/actions
before entering/exiting state actions
no need to support inner variables; I can use actions&conditions for it.
Is there any tool for it (preferably free)?
If not - is there any OpenSource (C# / JS) implementation of editor that supports all abpve without the stricting of conds/events/actions, that I could easily break in to it and add the requested strict mode?
Based upon your needs, my knee-jerk reaction of recommending Visio or Dia would be inappropriate here. You appear to require a tool with some form of an API or descriptive language to lock users to a constrained set of components Lemmings-style, and your needs would best be serviced by something relatively simple if possible.
I'm curious why altering the source code to SCXML-GUI (fsm-editor) or Violet would not solve your needs, however. You seem to indicate that an open source utility written in C# or JavaScript is most desirable, which I cannot easily locate.
But, in the interests of completeness, here's a comparable question that may help your search. Most notably, this appears to be exactly what you desire and may be worth purchasing.
Best of luck with your project.

Things you look for when trying to understand new software

I wonder what sort of things you look for when you start working on an existing, but new to you, system? Let's say that the system is quite big (whatever it means to you).
Some of the things that were identified are:
Where is a particular subroutine or procedure invoked?
What are the arguments, results and predicates of a particular function?
How does the flow of control reach a particular location?
Where is a particular variable set, used or queried?
Where is a particular variable declared?
Where is a particular data object accessed, i.e. created, read, updated or deleted?
What are the inputs and outputs of a particular module?
But if you look for something more specific or any of the above questions is particularly important to you please share it with us :)
I'm particularly interested in something that could be extracted in dynamic analysis/execution.
I like to use a "use case" approach:
First, I ask myself "what's this software's purpose?": I try to identify how users are going to interact with the application;
Once I have some "use case", I try to understand what are the objects that are more involved and how they interact with other objects.
Once I did this, I draw a UML-type diagram that describe what I've just learned for further reference. What happens after depends on the task I've been assigned, i.e. modify the code, document the code etc.
There is the question of what motivation do I have for learning the new system:
Bug fix/minor enhancement - In this case, I may focus solely on that portion of the system that performs a specific function that needs to be altered. This is a way to break down a huge system but also is a way to identify if the issue is something I can fix or if it is something that I have to hand to the off-the-shelf company whose software we are using,e.g. a CRM, CMS, or ERP system can be a customized off-the-shelf system so there are many pieces to it.
Project work - This would be the other case and is where I'd probably try to build myself a view from 30,000 feet or so to know what are the high-level components and which areas of the system does the project impact. An example of this is where I'd join a company and work off of an existing code base but I don't have the luxury of having the small focus like in the previous case. Part of that view is to look for any patterns in the code in terms of naming conventions, project structure, etc. as this may be useful once I start changing some code in the system. I'd probably do some tracing through the system and try to see where are the uglier parts of the code. By uglier I mean those parts that are kludge-like and may have some spaghetti code as this was rushed when first written and is now being reworked heavily.
To my mind another way to view this is the question of whether I'm going to be spending days or weeks wrapping my head around a system like in the second case or should this be a case where it hopefully takes only a few hours, optimistically that is, to get my footing to make the necessary changes.

Fluent mapping verification for Entity Framework 4

Note: This is a follow-up question for this previous question of mine.
Inspired by this blog post, I'm trying to construct a fluent way to test my EF4 Code-Only mappings. However, I'm stuck almost instantly...
To be able to implement this, I also need to implement the CheckProperty method, and I'm quite unsure on how to save the parameters in the PersistenceSpecification class, and how to use them in VerifyTheMappings.
Also, I'd like to write tests for this class, but I'm not at all sure on how to accomplish that. What do I test? And how?
Any help is appreciated.
Update: I've taken a look at the implementation in Fluent NHibernate's source code, and it seems like it would be quite easy to just take the source and adapt it to Entity Framework. However, I can't find anything about modifying and using parts of the source in the BSD licence. Would copy-pasting their code into my project, and changing whatever I want to suit my needs, be legal for non-commercial private or open source projects? Would it be for commercial projects?
I was going to suggest looking at how FluentNH does this, until I got to your update. Anyway, you're already investigating that approach.
As to the portion of your question regarding the BSD license, I'd say the relevant part of the license is this: Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: [conditions follow].
From my reading of that line, you can modify (which would include the removal of any code not relevant to your use cases) the code however you wish, and redistribute it as long as you meet the author's conditions.
Since there are no qualifications on how you may use or redistribute the code or binaries, then you are free to do that however you wish, for any and all applications.
Here and here are descriptions of the license in layman's terms.
I'm always writing simple set of integration tests for each entity. Tests are persisting, selecting, updating and deleting entity. I thing there is no better and easier way to test your mapping and other features of the model (like cascade deletes).

How to convert Together Support UML to generic UML

My problem is a simple one. I've created a class library for Delphi 2007 and added the modelling support to it that Delphi offers. It generates nice class overviews of my code, which I'd like to use. But it's not enough. I want to export the generated UML to Altova's UModel to generate some additional documentation and nicer-looking models.
I can't find a way to export the UML from Delphi, though. I can't even find anything in Delphi that would help me to generate any other documentation, except for the class model images that it allows me to save.
My main problem with my class library is that while it's usage is simple, it's creation was quite complex. I've used several techniques to encapsulate functionality, types within types, interfaces and delegations, type aliases and a lot more. The result is actually three simple-looking classes that only expose methods needed to call a specific web service with one class for the WS itself, one class to manage the input and one to manage the output. The class interface is thus kept simple to make it's usage simple. Unfortunately, the complexity of the WS required me to create some complex code.
I need to generate two kinds of documentation now for this code. One simple document that explains how it's used. That one is simple. A second one that explains how to maintain the code, what is where and how and why certain decisions have been taken. That one is complex and requires me to model the whole thing.
I have UModel, which is a great product, especially with C# and Java code. Unfortunately, it can't import Delphi code. I've tried Enterprise Architect, which can manage Delphi code, but this code happens to be way too complex. EA doesn't understand a thing about types within types and other features I've used. Also tried StarUML but had to cry after 10 minutes of usage since that product is just real bad... And doesn't even support Delphi... My hard disk feels real dirty now after I've installed it...
And while I could continue to try other modelling tools, I think I should have a better chance in findiing some way to convert the Together UML stuff to a regular XMI file.
You might want to try ModelMaker.
It has an add-on that allows you to export the UML as XMI, which you can import in Altova UModel.
ModelMaker supports both the Delphi and C# language.
--jeroen
I'm afraid there's no such thing as "regular XMI file" (see for instance this example, that shows the differences in the XMI representation of the same model depending on the tool you use).

Why Fit/FitNesse?

What's the point of using Fit/FitNesse instead of xUnit-style integration tests? It has really strange and very unclear syntax in my opinion.
Is it really only to make product owners write tests? They won't! It's too complicated for them. So why should anyone Fit/FitNesse?
Update So it's totally suitable for business-rules tests only?
The whole point is to work with non-programmers, often even completely non-technical people like prospect users of a business application, on what application should do and then put it into tests. While making tests work is certainly too complicated for them, they should be able to discuss tables of sample data filled out in e.g. Word. And the great thing is, unlike traditional specification, those documents live with your application because automated tests force you to update them.
See Introduction To Fit and Fit Workflow by James Shore and follow links to the rest of documentation if you want.
Update: Depends on what you mean by business rules? ;-) Some people would understand it very narrowly (like in business rules engines etc), others---very broadly.
As I see it, Fit is a tool that allows you to write down business (as in domain) use cases with rich realistic examples in a document, which the end users or domain experts (in some domains) can understand, verify and discuss. At the same time these examples are in machine readable form so they can be used to drive automated testing, You neither write the document entirely by yourself, nor requre them to do it. Instead it's a product of callaboration and discussion that reflects growing understanding of what application is going to do, on both sides. Examples get richer as you progress and more corner cases are resolved.
What application will do, not how, is important. It's a form of functional spec. As such it's rather broad and not really organized by modules but rather usage scenarios.
The tests that come out of examples will test external behavior of application in aspects important from business point of view. Yes, you might call it business rules. But lets look at Diego Jancic's example of credit scoring, just with a little twist. What if part of fit document is 1) listing attributes and their scores and then 2) providing client data and checking results, Then which are the actual business rules: scoring table (attributes and their scores) or application logic computing the score for each client (based on scoring table)? And which are tested?
Fit/FitNesse tests seem more suitable for acceptance testing. Other tests (when you don't care about cooperation with clients, users, domain experts, etc., you just want to automate testing) probably will be easier to write and maintain in more traditional ways. xUnit is nice for unit testing and api tests. Each web framework should have some tool for web app/service testing integrated in its modify-build-test-deploy cycle, eg. django has its little test client. You've lots to chose from.
And you always can write your own tool (or preferably tweak some existing) to better fit (pun intended) some testing in your particular domain of interest.
One more general thought. It's often (not always!!!) better to encode your tests, "business rules" and just about anything, in some form of well defined data that is interpreted by some simple, generic piece of code. Then it's easy to use the data in some other way: generate documentation, migrate to new testing framework, port application to new environment/programming language, use to check conformance with some external rules or other system (just use your imagination). It's much harder to pull such information out from code, eg. simple hardcoded unit tests or business rules.
Fit stores test cases as data. In very specific format because of how it's intended to be used, but still. Your domain specific tests may use different formats like simple CSV, JSON or YAML.
The idea is that you (the programmer) defines an easy to understand format, such as an excel sheet. Then, the product owner enters information that is hard to understand for people that is not in the business... and you just validate that your code works as the PO expects running Fit.
The way used in xUnit, can be used for programmers as an input for easy to understand or simple information.
If you're going to need to enter a lot of weird examples with multiple fields in your xUnit test, it will became hard to read.
Imagine a case where you have to decide whether to give a loan to a customer, based on the Age, Married/Single, Amount of Childrens, Wage, Activity, ...
As a programmer, you cannot write that information; and a risk manager cannot write a xUnit test.
Helps reduce redundancy in regression and bug testing. Build manageable repository of test cases. Its like build once and use for ever.
It is very useful during cooperation of the QA and devs teams: QA could show to developer the result of the failed test and a developer will easyly help to solve an environment issue and will understand steps for reproducing a bug.
It is suitable for UI and even for API testing.

Resources