Hodges' Model: Welcome to the QUAD: Rails

Hodges' model is a conceptual framework to support reflection and critical thinking. Situated, the model can help integrate all disciplines (academic and professional). Amid news items, are posts that illustrate the scope and application of the model. A bibliography and A4 template are provided in the sidebar. Welcome to the QUAD ...

Showing posts with label Rails. Show all posts
Showing posts with label Rails. Show all posts

Tuesday, December 17, 2024

NURSING -:- INFOTECH - worlds apart? Software testing

Another draft from over a decade ago ... duly revisited and updated:


https://www.statista.com/statistics/793628/worldwide-developer-survey-most-used-languages/

Reading up on Ruby and Rails and attending Scotland on Rails, I've been struck by the emphasis on testing. Testing in this context is about reliable software and building this into the 'product' from the outset. A book on Rails gets criticized because it leaves the chapter on 'Testing' until the end (even if the authors had their reasons - as they explained).

This take on testing is sufficient if (of course) it is appropriate and it is applied (as per the manual) to the application concerned. There are other more formal methods that extend to writing a specification for code which entails the use of formal specification languages such as Zed (as encountered in BA(Hons.) studies. This arises in situations were software is being developed for safety-critical situations. Clearly, robotic surgery, nuclear energy, and keeping an aircraft in the sky, take-off and landing are mission-critical. In the latter case a company is still dealing with life threatening loss of life that can follow, should the software system fail or more covertly introduce an error.

Reading about Rails, there are specific tests and these are provided as a result of scaffolding, a process whereby the bones of a web application are created within the Rails framework: with tests.

Rails creates a test directory for you as soon as you create a Rails project using bin/rails new application_name. If you list the contents of this directory then you will see:

$ ls -F test
application_system_test_case.rb  controllers/                     helpers/                         mailers/                         system/                          fixtures/                        integration/                     models/                          test_helper.rb
Source: https://guides.rubyonrails.org/testing.html

Rails uses a popular convention to organise and integrate the elements of a web application that includes a database, and dynamic interface. The approach is known as:

Models, Views and Controllers - MVC

MVC underpins several programming languages and frameworks. As displayed above, the tests that Rails creates have specific names and you can quickly see where they come from and how they encompass Rails (an essential property of course).

Today, I still wonder [ what's new! 😉 ] what is the equivalent to MVC in nursing? Models seems to fit! Over the years at many IT events, you can't help but reflect on nursing and its 'API' - application programming interface. Worryingly, in humanistic terms there is an instrumental potential in Hodges' model. If Nursing on Rails was a thing, what would the tests look like? Identity would be a feature, to demonstrate person-centredness, safety in medication and other treatment procedures. Is there a way to demonstrate the integration of care, and for a patient - the extent of holistic bandwidth? Of course, nursing comprises just a part of a clinical information system. It must be in sync in accord with other disciplines, medical and pharmacy and other multidisciplinary team members and yet ensure that 'nursing is visible'.

Previously: API : 'Waste not - want not'

Monday, April 20, 2009

Cash Transactions : Care Continuity

In programming major applications such as finance there is a need to ensure within the transactions and the database operations that mistakes do not occur.

The classic example is a transfer between two accounts:

def transfer(from, to, amount)
  from.debit(amount)
  to.credit(amount)
end
It is vital that the above method (example provided by Tate and Hibbs) does not fail after the debit. In Rails the transaction method help to prevent 'digital accidents' as follows:
def transfer(from, to, amount)
  Account.transaction do
   from.debit(amount)
   to.credit(amount)
  end
end
transaction is itself a method built into Rail's Active Record that helps to maintain the integrity of transactions. Which brings me to 'care'. ...

There are several blog posts here since you reach a stage in your career when the hard fought lessons of yesteryear have to be faced again but this time like after dinner wind.
There are many possible care transactions that arise.

Many have a specific context and frequently these are conjoined:
  • timing
  • relationships - trust
  • responsibility - transfer
  • care environment
  • record (paper, electronic)
As to care transaction consider these:
def transfer(from, to, care_plan)
 Care.transaction do
  from.hospital(care_plan)
  to.community(care_plan)
 end
end

def transfer(from, to, day_care)
 Care.transaction do
  from.home(day_care)
  to.day_center(day_care)
 end
end
Wherever, whenever, whatever and whoever your transactions involve, take care of them and remember in health and social care (esp.) outcomes add up.

Don't forget to look after the however: the information, the knowledge, the promises ....
def transfer(from, to, promise_plan_of_action)
 Care.transaction do
  from.nurse(promise_plan_of_action)
  to.carer(promise_plan_of_action)
 end
end
Reference: Bruce Tate, Curt Hibbs (2006) Ruby on Rails: Up and Running, O'Reilly, p.35.

Wednesday, April 01, 2009

Scotland on Rails 2009

1 April mmm... while it is not yet self evident I should by now have an all singing and dancing website. In fact maybe I should have two, since the conference score is currently:

DRUPAL :1 (Drupalcon Szeged 2008) Ruby and Rails :2 (Scotland on Rails 2008 & 2009)

Having just returned from Edinburgh and three days of presentation magic - not only were the speakers experts and leaders they all knew how to present - it's time for me to reflect a little.

Jim WeirichI took something away from ALL the presentations as I attended 'a full stream' mostly the sessions in the main hall. Jim Weirich's session on Building Blocks of Modularity was very interesting informatically, holistically and clinically as he explained and referenced “connascence”:

An examination of the concept of “connascence” and building modular programs.

Connascence: n.
* The common birth of two or more at the same time; production of two or more together.
* That which is born or produced with another.
* The act of growing together.


Connascence: undoubtedly a concept to add to 'consilience'.

Whether using Drupal or Ruby - Rails I'm conscious that you can create a website very quickly. As already ack. here last summer in Hungary Dan and James advised that I get something together and publish the beta. On Saturday Steven A Bristol stressed the same:

  1. Identify the essential thing you have to offer through a website / application;
  2. do not wait until it is 'finished';
  3. - speaking of which are you a techie or designer? Find the partner(s) you need, people are rarely both;
  4. ensure you include a feedback mechanism - not just e-mail;
  5. and 'get it out there'.
In their session Kevin McDonagh and Joseph Wright added that it is a waste of time appealing to the World. Of course Kevin did not realise how painful it was for me to hear that, but since this is certainly true - I have appealed to the world - it was very therapeutic. Unlike Kevin and Joseph's Green Map as a Community Project I'm not sure if whether I can appeal to the local community (despite an interest in ecology).

Dave Thomas of the Pragmatic Programmers by Fraser Spiers at SoR 2009Like Drupal the Ruby community is a terrific group of people - welcoming, supportive, cohesive - a bunch of real humans. The charity tutorial day raised £7,000 for CHAS the Children’s Hospice Association Scotland.

After Dave Thomas presented a fascinating keynote on the Ruby Object Model, Erin Staniland and Tim Harding confirmed I've the basic building blocks in place to create and execute a Rails application on my MacBook.

Peter Jones at SoR March 2009 image by Fraser SpeirsI am hooked on Drupal and Ruby. Some of the keywords and structures in Ruby are dangerous in their appeal - more on this to follow...

Driving (ironically) back to NW England I realised Earth Hour was in progress, hopefully there will be another one. That night Orion was beautiful chasing a fresh smiling new moon along the way...

Images: thanks to SoR site and Fraser Spiers

P.S. Kevin - I owe you a beer towards the taxi Friday night!

Monday, April 07, 2008

NetBeans, Eclipse and IntelliJ

I've made some progress getting to know Eclipse as a programming environment, but on Friday night (as per the post) I was told about JRuby (which I'd confused with IronRuby) and advised to take a look at NetBeans. So now it's installed, registered and yet another 'hello world' program has run.

Although I know little of Java I recognise an industry heavy weight when I see one. Walking past the coffee house at Oxford Road Manchester I often wondered wish I had time to get to know Java proper. Java's is too much for me and like the armchair astronomer I currently am, in theory so far Ruby has caught my eye and imagination. Behind Java though there is a huge catalogue of libraries and at present Ruby is written in Java.

Apparently the IDE of choice is IntelliJ, but this is not Open Source. I will download this too c/o a trial demo. Wonder if they sponsor worthy causes...? Following Scotland On Rails and Joe O'Brien's observation to focus on Ruby not just Rails, I must also use irb - that is interactive Ruby. It's copied on to the Eee PC now.

I'm working my way through the jQuery in Action book. One existing website page that will benefit from a review and recode is the FAQ. Already I'm thinking about what animations /effects it is sensible to use. It will be interesting to revisit the page created in response to Pippa's question on the humanistic-mechanistic axis. The jQuery used was lifted from a tutorial/blog site and although edited it probably contains some errors / redundant code.

I have not mentioned Drupal for a while, we'll get there.... There's another book on the shelf Learning PHP & MySQL. Must chase the new Drupal 6 book from Mercer too.

Friday night chatting another Ruby-Rails delegate in Edinburgh mentioned having been put-off by the prospect of tackling databases and then I realised: Yes, that's me too - the rabbit like eyes : the glare of headlights - it's all there.
Must seek some therapy, or get off the road....

Saturday, April 05, 2008

"Great Scot!" Ruby & Rails - Scotland On Rails

Just back from Edinburgh this evening. Took it steady about 60mph, so used just half a tank of fuel - not bad for 400 miles (return). Had to take it easy as it was just above freezing in places and I ended up playing Star Trek. It was snowing for a time North of Penrith. When I was able I put the head lights on full-beam: warp drive!

Scotland On Rails was great - the organisation, speakers, content and company. The sessions I attended included testing, testing testing, migrating to Ruby 1.9, DSLs .... and the last session on JRuby with the announcement of version 1.1 that provoked a round of applause:

JRuby on Rails: Up And Running!

Charles Oliver Nutter and Thomas Enebo

JRuby 1.1 has been released, and is becoming the Rails platform of choice for many Rails shops. In this session, we’ll show how to start from scratch or migrate your existing Rails app to JRuby. We’ll demonstrate the various deployment options on JRuby. We’ll show how to integrate Java libraries into your app. We’ll walk through NetBeans’ Ruby and Rails support and talk about how JRuby has enabled better tools and better solutions for Ruby developers. And we’ll have a conversation with the audience about where JRuby on Rails should go from here. Be prepared to talk shop and see lots of code and demos.
I'd been really looking forward to Joe's presentation on DSLs and was not disappointed. My enthusiasm here is not because Hodges' domains makes a DSL a dead-cert, far from it; it's just that I miss playing with Plasticine:
Domain Specific Languages : Moulding Ruby

Joe O'Brien

Ever wondered what all the fuss is about when it comes to DSL’s and Ruby? It seems to be all we hear about. This talk will peel away the onion and look at what it is about Ruby that makes it the perfect candidate for creating your own languages. I will show you, through examples, how you can create your own languages without the need for compilers and parsers. We will also cover some real world examples in areas of Banking and Medicine where DSL’s have been applied.
Amid the clamour that is Rails, Joe also stressed that people should focus and explore Ruby itself. Something I need to get on with. Paul Dix's talk this afternoon was fascinating in terms of scale, processing, math libraries and mention of clustering:
Collective Intelligence: Leveraging User Data to Create Intelligent Rails Applications
Paul Dix

Take advantage of user data to create intelligent Rails applications! This talk will focus on data mining to create complex application behavior and gain insight into the patterns and habits of your users. Examples of these techniques can be seen with recommendation systems like those created by Amazon, Netflix, last.fm, and others. Additional examples include spam filtering systems for email or comment filtering provided by Akismet.
I will focus on techniques for gathering data, specific gems and plugins for performing various data mining and machine learning tasks, and performance issues like how to distribute the work to separate servers. Theory in this talk will be light and the specific algorithms will only get a mention by name. We’ll be looking at real world Ruby and Rails code examples for building recommendation, ranking, and classification systems.
I wasn't the only Ruby newbie and met a few of my peers, we noticed on the first day the number of sessions on the theme of testing. Last week I'd watched Matz' February talk on Ruby 1.9 and the future which helped me out through the past two days. Last night in The Crags one of the speakers Ritchie (whose session I missed) kindly explained about his conjoint talk and the significance of JRuby, NetBeans IDE and IntelliJ. Given Richie's knowledge, experience and that closing session, I'll definitely investigate these.

There's only one conclusion - totally overwhelming: but totally worth the brain ache.
So great job and many thanks to Alan and the team, plus the luminous speakers and sponsors.

Saturday, March 29, 2008

Week ahead: Ruby/Rails conference and next paper?

It should be a stimulating week ahead as the clocks spring forward (why not two weeks ago?) and I check the schedule for Scotland on Rails and plan the sessions to attend. Now with a new Eee PC I should also have something to write on and connectivity.

Yesterday jQuery in Action arrived. I've started to read it and am finding already that the two CSS books that were until recently just sitting on the shelf are helping me to grasp what jQuery is about. One of those titles - Keith or Cederholm - highlighted that learning CSS helps you to understand and learn other languages and this really does seem to be the case. jQuery in Action will definitely be travelling to Edinburgh. Even though I'm only at chapter 2 it's a good read. There's a Selector Lab a web page to enter jQuery selector strings and see how the code relates to the DOM (document object model).

Over the past week I've been investigating Ruby graphical user interface (GUI) toolkits - specifically Tk (must check version 8.5). Just as with Drupal and settling on a theme, eventually - it seems? - I will have to choose a GUI. For now it's a case of seeing what they offer and how to run them within Eclipse (and without). The jQuery book will help push me with Drupal and enliven what will be essentially be static (archive) content:

  • Archive - Brian's original notes; my introduction
  • Biographies - Brian, myself - and who knows other contributors
  • Chronology
    • - still thinking about other content
      • old - e.g. the informatics pages
      • and new - a h2cm collaborative book.
There is no word as yet about the socio-technical chapter submitted in the new year, which may be good news? Although there's enough going on above, I like to have a paper on slow cook. So, we will see what arises on mapping, concept organisation ... in health care, communication and education. As a starter (c/o free access to SAGE journals) there are several papers on intervention mapping within public health and health promotion that will be essential reading. Another ingredient to (potentially) add to the mix - I've long wondered about case formulation within psychological therapies and Hodges' model. Time to make a start, but real slow like...

Sunday, March 16, 2008

BASIC, Ruby, DATA and Scotland On Rails

This weekend reading more of Hal Fulton's The Ruby Way, there was a blast from the past in the form of '10.1.25 Reading Data Embedded in a Program' and a reminder of all those DATA statements typed in from magazines.

Ruby not only supports the industry database and SQL standards, but other approaches such as embedded data and KirbyBase. Fulton's book is designed for 'random access' and yet I'm reading it through. There are jewels in the texts on Ruby. Sentences that while fairly obvious still serve to catch my breathe '... They differ in the amount of context they copy. ...'

10.4.7 Object-Relational Mappers discusses ActiveRecord and Og (object graph). Apparently Og can generate a database schema from Ruby class definitions (rather than vice-versa). This is a useful and powerful ORM 'especially if you design your database after your objects.' p. 384.OK ....

With all this reading on databases whatever happened to the Associative Data Model? Still alive and very well I believe, yet more Sentences to figure out.

In order to try and make some headway, next month I'm heading for Edinburgh and the Scotland On Rails conference.

I can't attend the full event, but plan to make sure the trip is well worthwhile. While I hope all the speakers stay in fine fettle, there is a speaker for Saturday whom I pray stays in finest lustre - a presentation on DSLs! Just one highlight of what should be a great talk. [Stay well Joe!]

Tuesday, March 11, 2008

Ruby Holistic I

Using BBC BASIC many years ago as I recall I used an array to capture user input and then save this data to files.

I've just written a very simplistic Ruby program, not very Rubyesque in its code style to capture some data and store this in an array. There are many options here and not limited to:

  • declaring an array from the outset;
  • using a hash;
  • using MySQL.
At present it's just about getting used to the Ruby syntax. I have yet to write a class and methods of my own and resort to file handling. Looking forward to doing so. Not far into the Ruby on Rails book it was getting very interesting so I need to pick that up again too...!

Also need to get back to Drupal and the new versions of Brian's notes and my introduction to the model and website. How many themes and modules are Drupal 6 compatible now? It's the NW England Drupal user group meeting again on the 20th in Manchester.

Sunday, November 18, 2007

Ruby, Eclipse AND Rails

Last February I mentioned here that I was going to try to learn Ruby. Regardless of the name, it really seems to be a gem of a programming language. Finding Eclipse -

Eclipse is an open source community whose projects are focused on building an open development platform comprised of extensible frameworks, tools and runtimes for building, deploying and managing software across the lifecycle. A large and vibrant ecosystem of major technology vendors, innovative start-ups, universities, research institutions and individuals extend, complement and support the Eclipse platform.
- also made me hungry again (after some 12-15 years) to tinker with code. After installing and trying Eclipse and Ruby in the spring - time got the better of me.

Then last week I read an item from October's PC PRO - 'A total Eclipse'.

I removed Ruby, who am I trying to kid!

It was time to check out Ruby AND Rails -
Rails is a full-stack framework for developing database-backed web applications according to the Model-View-Control pattern. From the Ajax in the view, to the request and response in the controller, to the domain model wrapping the database, Rails gives you a pure-Ruby development environment. To go live, all you need to add is a database and a web server.
I installed INSTANT RAILS and it's awe inspiring; so much to learn, but it really feels like the motor's running. I've had the Rails book since the spring with one reading and now the mini library (Ajax, PHP, Drupal, DOM Scripting) I managed to put together is paying dividends (I think!).

So now Aptana is plugged into Eclipse and I'm up to Part II - Building an Application (just to put things into perspective that's p. 51/719 actually!).
If you follow this blog, you may be thinking he has dropped Drupal! Far from it. I can't wait for this Wednesday night and the meeting at Manchester Digital Development Agency. Books aren't the whole story: I have to add that installing Drupal, screwing up, deleting, installing again and finding some stability at last... such that I can check out the innards of Drupal (play!) has helped me enormously in starting with Ruby, Rails and Eclipse. Hope I can maintain this momentum.

I've also noticed the ads for Ruby and Rails hosting too - wish I could find a sponsor or two...

Spreading the cognitive and temporal jam yet further - I've downloaded Inkscape's Vector Graphics editor. Still need a decent banner (and finish the socio-tech paper - must contact the editors!).

Saturday, February 10, 2007

"Ruby don't take your code to town"

Sinclair ZX81When the home microcomputer boom took off I learnt BASIC programming on a Sinclair ZX81 and then moved on to BBC BASIC in 1982-3. Since then I've never managed to program on a PC. I kept the day-job, but those hobbyist coding days (and nights) were really enjoyable.

Several computer programs were produced that sold in nurse education:

BBC microcomputer 1982

  • Nursing Process
  • Computer Assisted Nursing Assessment
  • Blood Groups
  • Shades of Grey (nuclear weapons simulation)



In the 90's I looked at C++ and Smalltalk, but nothing happened. The first pit-a-pat of tiny feet in 1985 was the key factor. Now in 2007 the h2cm website needs revising. I'm undecided on how to tackle this; a content management system is a possibility? While doing some reading/browsing though, I've discovered a computer language with an enticing shine.

RubyI've decided to try to learn Ruby. Whether this will lead anywhere remains to be seen, but it's fun and challenging just to enthuse a little. There's a tutorial that is encouraging, intriguing and additional tools that support Web 2.0 and Ajax look well worth the effort. Now with Ruby installed, I've run the ubiquitous "hello.rb" program using the Eclipse development environment - that's a start.

Maybe in future posts we can compare programming and nursing? That said, there doesn't appear to be any direct connections in this book. That's one birthday present sorted!