Monthly Archives: March 2015

eaForms – using the eaForms action buttons !!

A couple of weeks ago I outlined my view on the usefulness of lists when editing EA elements. In that post I illustrated the ability to add buttons to an eaForm which could be used to initiate some action such as adding a property.  By providing buttons that initiate action we provide a means to perform the task with minimal context switch and hence minimal effort.

SimpleClassForm illustrating use of buttons

A Simple Class Form illustrating the use of buttons

If we look at this example form we see standard buttons to Save or  Cancel our element editing. We also see buttons which allow us to Add… properties to our element. For example,

Adding an attribute presents simple dialog within context of open element

Adding an attribute presents simple dialog within context of open element

our Add Attribute button will present an attribute form within the context of our already open form – no switching just a single button push.

We have a range of other buttons which cwe can use to add element properties (often they are are specific to the relevant element type) – for example:

  • Add a tagged value
  • For Use Cases we have add Actor, Pre-/Post-condition
  • For Classes we have add Attributes/Operations

We also have a Detail button that can be added to the form and will save updates to the current element then open the element using the standard EA properties editor; a button we feel is useful for the experienced EA user who may at some time wish to switch for an instant.

Create related note or element

In my experience in addition to editing element properties the other may task is to add stuff – notes or new elements related to my current element, so we have added buttons that assist with this task. The example below illustrates a add a linked element button – which when pressed presents the user with a dialogue to enter basic information about the element and its relationship to the current element.

Add linked element to our current element

Add linked element to our current element

Button options include both linking and / or owning the element.

Also, although not a button, within eaForms we offer the related element control which allows the designer to specify a desired connection between the element that the user is editing and another element (optionally with a specific stereotype) and with a specified connector type.

Script buttons

During recent work we have seen the benefit of scripting and have been working with some “experimental” buttons within eaForms that will not only save or potentially save an element but also run a script.  At present we have included 2 script buttons:

1. Save and run script after save – which will save updates to the element and then execute a predefined script, performing some post saving action.  For example, we could add an entry to a file to indicate that an element has been approved or some other project relevant event.

2. Run script and conditionally save the element or remain in edit – this button runs a script and depending on the outcome will either save any element updates or stay in editing mode, without saving any updates, and so presents the user with making any relevant modifications or preventing them saving updates that do not confirm to some project specific standards.  By proving the option to perform pre-saving checks we can help ensure the integrity of the project.

In providing these button options we recognised the potential for issues with scripts.  The first is which script to use and where it is located, so we decided to include the script within the eaForms definition.  So if we look at a very simple form with a script button and its control definition we see the script code can be edited – this script adds an entry to a file

A script button and its definition

A script button and its definition

The second issue is the operation of the script – in our early release we have limited the scripts to VBScript and further do not support INC’s – and hope that is not too restrictive.  We have found that most of what we would see as needed is readily available within the existing windows environment e.g. the use of the File System Objects.  We will review this in due course.

Finally, are there other script buttons that would help. Do we want to include a “Run Script” button that performs a task without doing any pre-defined action?

At present these script buttons are at an early stage and the use cases may be a bit vague but part of the reason for including them was to see if they help the user or other aspects of model quality – which is part of the aim with eaForms

Summary

In this post I have outlined the use of buttons within eaForms –  from the simple add properties to the more powerful buttons with scripts that provide the user with the flexibility to do their own thing.

As always hope this is of interested and welcome your questions and feedback.

Adrian

Advertisements

eaForms – is there a need for a simple EA client to help get people on board?

You may have seen, if you’ve reviewed information about our eaForms product, that one of the key reasons for the AddIn was to help overcome some of the issues we have experienced when trying to get people to use EA.  We have found that there are a set of people that I refer to as “reluctant users”, and from whom you may want them to contribute to the project by:

  • Providing Information – adding new packages/elements
  • Reviewing, editing or generally providing feedback
  • Approving items in the project

Needless to say, some of these people are just not be interested, whilst some may be willing to provide this information in a document or spreadsheet.  The former is the biggest challenge whilst the second will involve potentially time consuming, error prone work in harvesting the required content. Furthermore, if I’m the person doing the work, and not gaining any real insights into the project, I really don’t feel it’s good use of my time.  Yes there are tools to help (here’s a plug for eaDocX – it can readily import information from Excel; I wrote the Excel part following years of using VBA to get Excel content into EA – and it really does help!), but although a great help wouldn’t it be better if the creator of the information was able to work directly with EA?

When trying to introduce EA into a project I am sure we have all witnessed a mixed range of responses from those who:

  • see it, understand what EA offers and just can’t wait to get started

to those who:

  • aren’t interested, don’t understand why “another tool” and certainly don’t want to have to learn a new tool, and don’t have the time and will find any excuse to avoid meetings/trainings – the worst of the “reluctant users”. And unless remaining in their job depends explicitly on using EA they won’t, and it’s yours truly who will be picking up the pieces to ensure the completeness of the project.

So with eaForms we aim to help by reducing the perceived complexity of using EA, making it easier for users to get on board by reducing barriers to entry, and importantly, with the help of the local project experts, ensure that the editing forms meet the specific needs for the project and its users.

For an example Use Case form we only included the information our BA required using simple controls to help with the data input.  Also in hiding tagged values and using dropdown lists to limit input values to a pre-defined list we made it clearer what information was needed and any choice restrictions that should be applied.

eaForms AddIn Use Case form for our Business Analyst

eaForms AddIn Use Case form for our Business Analyst

We were thinking about our reluctant user’s and wondered whether it was possible to use the same form definitions we create with eaForms, but instead of within an AddIn use them within a simple standalone client that would.  In taking this approach, we could remove the need for the user to open EA and potentially, further reduce the barriers to using EA.

To test the idea we have produced a simple prototype client (illustrated below), with minimal menu options; we only offer – open and close an EA project, edit an existing element selected from a project browser and add/delete elements using editing forms defined to meet your project needs.

eaForms prototype client with same Use Case form

eaForms prototype client with same Use Case form

Using this client the user sees a much simplified interface and no longer needs to open EA and potential be confused or intimidated by the great range of options.  Remember our aim is to get users on-board quickly, so we hope that our eaForms client will provide either the new or reluctant user with a means to be included directly in the project work within minutes.  To be clear this is not a substitute for most EA users and is certainly not a powerful feature rich client but provides a simple means to capture important information into our EA projects without the existing EA users having to convert documents (Yippee!).

With the flexibility of eaForms the element editing forms can be tailored to meet users needs by project users.  They may include simple or complex controls, richer “gadgets” and action buttons to perform project specific task plus the ability to drive consistency of data input through value selection rather than free data text.

NB: Before I continue, there will be many, including myself, who feel users need to overcome their resistance to learning some UML and get to grips with EA.  But as we all know we don’t live in an ideal world, and have to adapt. So if our client provides a means to ensure that those that should be involved with our projects are, then we must surely increase the likelihood that we will have better projects.

Now it is my turn to ask you a question. We have a very small sample set of customers and hence we are interested your views. As a reader of this post it is more than likely that you are a committed EA user, so no need for this client, you are not the target audience (although eaForms may be of interest), however you may work with people that you would like to be users.

  • Who are they? What are their roles?  What tools do they use when they should be using EA?
  • What would they need for a tool?
  • Would providing them with a simpler client help them better understand the value of EA and hopefully lead them down the path to becoming a real committed EA user? Would having a simple client help you, if only to reduce all the harvesting that you may have to do!
  • Does the concept of a simple client make sense?

These are just some of the questions we are asking ourselves, there are many more we should probably be looking at and with that in mind are keen to get your feedback on this idea.  Please add a comment to this post or send us an email at eaforms(at)exploringea.co.uk

I look forward to hearing from you.

Many thanks

Adrian

 

eaForms – using lists to access element and related information

Each EA element has a range of collections which contains information about the element or related “things”.  Just a quick look and you will see a range of collections associated with each element, for example:

  • Attributes
  • Methods
  • Connectors
  • Diagrams
  • Elements
  • EmbeddedElements
  • Requirements
  • TaggedValues
  • Files
  • Metrics
  • Realizes
  • Resources
  • Efforts
  • Risks
  • Issues
  • Tests

Depending on your role and/or stage in a project you may be interested in some or none of these bits of information.  But as a collection of relevant information it can be useful to have a view of them during your work.  To access most of these items with EA you will often need to make a menu selection.   However, as we may use some of them frequently wouldn’t it be useful if we could see them without this need for additional user input.  When developing eaForms it was our view that having visibility of the required information at the same time would be useful when adding or editing elements;   the ability to see the information at a glance plus the ability to add a new item using an action button was our vision.

So with eaForms we have provided a list control whose data source can be set to display a wide range of collections.  Furthermore, within these lists we have added the ability to select and open the related item for example with Use Cases (Actors, Pre/Post conditions), Classes(Attributes and operations) as well as requirements and other related items for which we can interpret the target item (at present we have added what we see as the useful stuff).  This allows the user to work within the context of the current opened element to view and edit the related information.

As an example, let us start with a look at a simple requirements form were we have included a list of linked items:

Simple requirements form list related items

Simple requirements form list related items

We can double click on an item in this list to open the relevant  item – in our example another requirement (we can drop down into other elements as required)

Opening a related item

Opening a related item

As a more complex example let us look at the Use Case form below – which includes linked actors, pre-/post-conditions, tagged values and linked items

Use Case example with several lists

Use Case example with several lists

To this form we can add action buttons to this form – as modified below – where we also illustrate adding on a new post condition within the current element editing context

Use case example with action button - to add a new post-condition

Use case example with action button – to add a new post-condition

Of course, what you place on your eaForms is up to you, that was the core idea behind eaForms. The ability to adapt the editing forms to match both the needs of your project and the users working on the project is key.  With eaForms you not only select the content but also define the layout and its presentation (look and feel) to meet your specific needs.  Having lists is one of those features that can help present the information in a better way for you.

I hope they provide you with the information you need.  Feel free to let us have your wish lists of additions.

Adrian

 

Scripting follow up on case #6 – prevent execution of script on AddCode – solved??

When researching information for my recent scripting experiments one of the posts I came across highlighted an issues that when adding the script code using the Script Control addcode method the script would execute. The post cited was a simple script:

 sub main
  MsgBox("main executed")
 end sub
 main

I had also observed a few cases myself but it appeared inconsistent.  Now I’ve come back to look at the problem, by just looking at the code with fresh eyes the solution was obvious, wasn’t it?

If I step back to the early 1970’s using basic interpreters, I entered the subroutines/functions then added a line to specify what routine to call. At which point the code would run. So if we look at the code example we see the subroutine plus a line “main” which I can only imagine is saying run “main”.  A quick check with my EA Script Tester AddIn, and yes this appears to solve the issue.  I removed the last line i.e. “main” and the AddCode just adds the code without running, and the run does as we expect.   And to check, putting “main” at the end and the script runs immediately on adding the code as well as when requested to run.  BTW: I’m not sure that is what was referred to as the solution, which referenced needing to strip out the calls; however I felt it was worth checking out so I understand the rules.

Now just as I am cautious and curious I ran a few more tests. I started with a script that included a few subroutines.  Ignoring setting parameters and any required objects the basic code consists of:

 myScriptControl.AddCode(myScriptAsAString)
 result = myScriptControl.Run("NAME OF SUBROUTINE TO RUN")

So if I create a new script, as below, which has several subroutines I performed a few tests.

sub main
 msgbox("Hello")
end sub
sub A
 msgbox("A")
end sub
sub B
 msgbox ("B")
end sub
main
  1. Running the code as illustrated it ran twice.
  2. I then removed the last line (“main”) and it only runs with the .run method is set.   Worth noting that you can specify any subroutine name and it will run accordingly. But don’t forget that if the subroutine has parameters you need to configure and set the parameters object as the second argument of the run call as well as set up any dependent objects.
  3. I added calls to the subroutines between them and yes it does execute on loading .  In testing it looks like all the code is loaded and then executed.
  4. Finally, I added one or more of the subroutine names at the end of the script and as I would expect it would run them in the defined sequence.

In practice, when running EA scripts either in an AddIn or external program, to ensure the code isn’t executed when added we need to strip out any lines containing a reference to a subroutine in our script that are NOT contained within a function or subroutine otherwise they will instruct the script control to execute upon adding code.  This was included in the initial post and although it may be a challenge not sure there is anything else – it’s the way the “interpreter” works and I guess for backwards compatibility will always work.

Of course, we could want this behaviour – in fact I can see a case where some subroutines run to initialise “stuff” before a call is made to a specified subroutine – up to the designer/user.

Having looked at a lot of documents on scripting in windows during my recent experiments I can’t recall any reference to the behaviour outlined above, although there are references to a distinct lack of documentation about the script control in general and perhaps this is the real issue!!

I hope this is useful, and if there are other “script funnies” I’d be interested to here.

Adrian

PS: This was the issue highlight in my test Case #6 if you are interested.

Scripting follow up on case #7 – can a script call a running EA AddIn

Calling a running AddIn from a script was has been a really interesting issue – read the original post for the background to this use case – and with some useful observations from my associated post on the Sparx Forum.

I have explored further, and not quiet managed a workaround, and as outlined in this post do not expect a viable practical solution, but in the spirit of sharing my findings and coming to this conclusion, here is an outline of my experiments.

A test DLL

To help work discover what goes on with an EA AddIn, I produced a small AddIn(DLL) – called DLLTester.  It’s main purpose was to be a very simple, normal EA AddIn with the added benefit that I could use it capture relevant system information that could help in investigating “the issue”.

EA and scripter do not share a DLL

Thanks to Geert who pointed out what appeared to be a very simple solution.  Based on windows documentation and various posts it looked like our AddIn DLL code would only be loaded a single time by the EA, process and if subsequent instances were required, they would share the same code. This would mean that static data would be shared across the different instances.  So if during the initial load we store a reference to our AddIn as a static variable, it could be retrieved by all subsequent instances as required.

In my initial test, I run EA and my AddIn loaded (the initialisation worked fine).  I then create a new object in the script (see code below).  And based on the premise that there is only a single copy of the DLL loaded, I would expect the code to be the same as the already loaded AddIn DLL, and hence the static data would already be initialised, and readily available as a reference to the required DLL.

Set myDLL= CreateObject("DLLTester.DLLTester")
Set myAddInRef = myDLL.getRef()

However this was not to be – I found that the static variable retrieved by my script was not set, and hence the was not the same code.  Upon further inspection, using Process Explorer  (see from the screen shot below), I found that EA and its Scripter engine exist in different processes (see PID) and hence their DLL’s are clearly different.

Both EA and SSProfile32 have a copy of the DLL

Both EA and SSProfile32 have a copy of the DLL

The fact that they are different processes not only prevents an elegant solution but dare I say a practical safe solution at all,  unless we start looking at using interprocess communication(?). Now even with my early background in writing operating system software (RSX, VMS – I am that old!) and that one of the key people behind both those operating systems and windows (Dave Cutler) which could suggest a common approach to the windows internals, I still wasn’t encourage to explore, perhaps another time.  So I think I’ll have to park the idea that we can implement case #7 “call an Addin from a script” for the moment.

However, before finishing, and purely out of interest I was keen to have a quick look at what I may be able to find. So here are a few things I did.

Looking for more information about the EA copy of the DLL.

Never one to give up I reckoned there was a means to get more information.  As we know that the parent of our Script control is EA, and the required DLL was a child of EA,  so we should be able to trace back and get some information. The steps I followed are:

  1. Get out process ID
  2. Get the process ID of our parent – EA
  3. Get information about the modules that EA had loaded

1. Get our process ID

To start with we need to know who we are, by which I mean what process are we.  Using some code I found stackoverflow (see below) I was able to get the process ID of the script control.  Basically, the method used creates a child process, we then inspect its parent id which is us, the script control.

Function MyProcessID ()
 MyProcessID = 0 ' Initially assume failure
 Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
 If objWMIService Is Nothing Then Exit Function ' for Guest and super-limited accounts
 Set objWshShell = CreateObject("WScript.Shell")
 Set objChildProcess = objWshShell.Exec ( """%ComSpec%"" /C pause" ) ' Fork a child process that just waits until its killed
 Set colPIDs= objWMIService.ExecQuery ( "Select * From Win32_Process Where ProcessId=" & objChildProcess.ProcessID,, 0 )
 For Each objPID In colPIDs 
 MyProcessID = objPID.ParentProcessId ' Return child's parent Process ID, i.e. my PID
 Next
 Call objChildProcess.Terminate() ' Terminate our temp child
 End Function MyProcessID

2. Get the process ID of EA

With the process ID of the script control we can easily get the process ID of the parent i.e.EA using the following code:

 Function getparentid(pid)
 Dim parentid 
 parentid = 0
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
 Set colItems = objWMIService.ExecQuery("Select * from Win32_Process Where ProcessID = " & pid)
 For Each objItem in colItems
 if objItem.ProcessID = pid then
 parentid = objItem.ParentProcessID
 end if
 next
 getparentid = parentid
 end function

3. Find EA loaded module information

Using the process ID of EA we can get information about the EA process and specifically look for modules it has loaded; this should include our target AddIn DLL.

This is where life started to get a little more difficult, in that I was unable to work out how to do this using VBScript, so I had to resort to some real coding to access the required system information.  For simplicity of testing, I added the code to my DLLTester using functions that would return details for loaded modules as needed.

Below is a snippet from one test function.  Using the the process id (pid) of EA as the input it iterates through the modules, finding our target (“DLLTester”) and the outputs the required information.

 Process p = Process.GetProcessById(pid);
 MessageBox.Show("Process " + p.Id + " Module count = " + p.Modules.Count);
 foreach(ProcessModule module in p.Modules) {
 answer += "\r\n.." + module.FileName;
 al.Add("\r\n.." + module.FileName);
 if (module.FileName.Contains("DLLTester"))
  {
   myDLL = module;
   String moduleInformation = "Module information for " + module.ToString();
   moduleInformation += "\r\n Module name: " + module.ModuleName;
   moduleInformation += "\r\n Base address: " + module.BaseAddress.ToString();
   moduleInformation += "\r\n Entry point address: " + module.EntryPointAddress.ToString();
 moduleInformation += "\r\n Memory size: " + module.ModuleMemorySize;
 moduleInformation += "\r\n File name: " + module.FileName;
 MessageBox.Show(moduleInformation);

This worked fine.  If we ignore the cross process nature of our initial use case, and the real risk it could cause a crash or 2,  would it be possible to obtain more information, for example a reference to our module which we could use.  Well I explored a range of classes, for example:

But after an hour or so I had more information but nothing that provided me with a usable object. So I have to acknowledge that my lack of detailed knowledge of the windows internals probably means I won’t solve this and so for the time being I will gracefully going to step back from this challenge. However, if anybody does have a practical solution I’d be really interested but somehow I don’t expect one to exist (there’s a challenge!).

Before I end what I did discover during this experiment were a few useful items that may be of interest to others:

  • If you want to use get the list of DLL from the modules in a process there was a change at .Net 4 which means that managed DLL’s are no longer included in the list of modules – see stackoverflow for more information.
  • Then if you are using .Net 3.5 you may see that VS does not load your modules in debug mode. This is due to an assumption that the default framework is .Net 4.  To resolve this you need to place a configuration file name EA.exe.config in the EA.exe program directory (on my system C:\Program Files (x86)\Sparx Systems\EA) whose contents are:
<configuration>
 <startup useLegacyV2RuntimeActivationPolicy="true">
 <supportedRuntime version="v2.0.50727"/>
 <supportedRuntime version="v4.0"/>
 </startup>
 </configuration>

Useful tools include:

  • System internals – I’ve used these a lot over the years.  In this experiment I used – Process Explorer – worth checking through, as are  the other tools as there are a range of utilities that may be useful at some time.
  • OleView – an OLE/COM Object Viewer, which is provided in the Microsoft Windows Kits and could well have already installed on your system if you are running VS – also check through this directory for other useful tools (e.g. Orca for checking any msi’s you create)

Well I know this is not really about EA but more about windows programming, but then I’ve found that more than half the issues with producing an EA AddIn is about windows!

Until the next time.

Have fun EXploringEA.

Adrian

 

Scripting follow up on case #5 – running an EA script from a windows application

A short follow up on one of the outstanding items from a previous post on scripting.

Thanks to quadrabyte for his feedback, including his code extract, which forced me to re-read what I had written, and which with hindsight wasn’t very clear; sorry to all those I may have confused.

When I set out the use case (#5) – “WinApp can run script within EA repository” – I was really thinking about a WinApp making a call to EA, through an api which would run a pre-defined script on my behalf.  This followed on from my idea that it could be useful to be able to run a script each time EA was started e.g.

>EA.exe /script="name"

This would allow a range of functions to be performed to help with the administration of my projects.  However, I couldn’t see a way of doing that with in a command line (anybody know?), but was there a way I could emulate the behaviour with a windows application that could start EA and run the script e.g.

myWinApp /script="name"

Well it was looking at the code quadrabyte provided that put me back on the straight and narrow, bringing me back to a world of logic from my roaming into fantasy solutions.  How could I have launch the EA UI and, in parallel, get it to perform functions for me.

However, it is clearly possible to have a windows application running a script – as outlined in previous posts  using its own ScriptControl.   Our windows application could open an EA repository, read and run a user script, provided we ensure that the required objects are initialised prior to running the script.

Although back in my fantasy world wouldn’t it be nice if EA would execute pre-defined scripts on start up, for example start of build scripts, workflow etc.  Perhaps it does and I haven’t found it or perhaps it’s another future feature.

In the meantime., thanks again to quadrabyte.

Adrian

PS: I’ll be following some other short posts on the other issues that were highlighted.

A little update:

Today I was having a quick look at what next and was reviewing some of my experiments with workflow scripts – and reminded myself that when an EA project is opened that EA will call the “Function GetWorkflowTasks” – and so why wouldn’t I use this to run my own scripts on startup?

A few quick tests:

  1. I found some of the capabilities I’ve used previous not working – so need to find out which
  2. Using a message box isn’t a good idea as I found it is hidden and not readily accessible. So probably not a good idea.
  3. I tried using the EA Dialogue and that didn’t work
  4. Accessing files seemed to work file

I would need to do a lot more checking to see what is available – but it does, in part, provide a means to address the task in hand.