Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

Sunday, December 4, 2022

Storyboard in iOS

 Disclaimer - I am in the process of learning iOS and SWIFT application development. These are my learning notes with the hope that it can be useful to someone out there.

storyboard is a xml document representation of UI view. Here I have broken it down to very basic elements. As you can see a storyboard consists of one or more scenes. Each scene has a ViewController which contains view with subviews. Some of the views such as StackView can further nest other views. There you go, it is simplified now.

<document>

<dependencies>...</dependencies>

<scenes>

<scene>

<objects>

<viewController>

<view>

<subviews>

<imageView>..</imageView>

<stackView>

<subviews>

<label>..</label>

<stackView>..</stackView>

<slider>..</slider>

..

</subviews>

</stackView>

<button>..</button>

..

</subviews>

</view>

</viewController>

<placeholder>..</placeholder>

</objects>

</scene>

</scenes>

<resources>

<image>..</image>

..

</resources>

</document>

Thursday, June 19, 2014

What is IBM Worklight

Many people have confusion about what is this product offering from IBM. To know fully they have to go through lots of documentation. In this post i am trying to provide a nutshell of my understanding of IBM Worklight.

Worklight is an eclipse plugin for application development just like maven plugin or ide to create other Java/web applications.
It contains embedded worklight server, so that you can deploy and test your applications from the eclipse environment itself.

Worklight applications can be of 2 types

    1) Serverside adapters : Using adapters you can retrieve data from another webservice (SOAP based or REST based) or from your backedn DB or from JMS queue. All the adapters return data to worklight application in JSON format.
   
    2) Client applications : Using worklight studio you can develop web based (HTML5), hybrid (web component and native component) and native (specific to mobile platform) client applications for both android and iOS environments.

For more information on IBM worklight you can refer to extensive documentation at

http://www-01.ibm.com/software/mobile-solutions/worklight/components/mobile-development-platform/

http://www.ibm.com/developerworks/downloads/ws/worklight/

https://www.ibm.com/developerworks/community/blogs/worklight/?lang=en

Thursday, August 29, 2013

How do CDN (Content Distribution Networks) work?

These days i am trying to read on how performance of high volume websites like google, amazon, linkedin etc is managed.

And one of the highlighting fact is the use of CDN to serve static contents. So to find out how does CDN work i found a very nice article

How do CDN (Content Distribution Networks) work?

Wednesday, February 13, 2013

Oracle : Finding tables with given column name

One of my colleague today come to me asking where  can i find this column (LANDING_PAGE) in DB of our application. Actually he was not even sure of the column name. It was a field in UI. Our application has more than 200 tables and my tables are heavy (having many columns). So human search was futile. Thankfully there is a query in oracle which came to rescue.

select * from user_tab_columns where column_name like '%PAGE%';

Thursday, December 23, 2010

A Sample Web Application - 2 (Junit & Emma)

This is in continuation with my previous post


Now i have added following
  • Junit
Junit is a unit testing framework for Java. To use Junit with maven all i had to include it as a dependency in pom.xml

Then i wrote a test class (MatchingUsernamePasswordValidatorTest) for testing the isValidLogin(IUserContext) method of class (MatchingUsernamePasswordValidator)

As you can notice the test classes name just appends Test to the class name being tested.

This test class contains 2 tests. One for the happy scenario in which user name and password matches and another for negative scenario in which username and password don't match.

Now run
$mvn test

At the end of the output you can expect to see something like this

-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running mayank.anup.ecom.login.MatchingUsernamePasswordValidatorTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.125 sec

Results :

Tests run: 2, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
  • Emma
Emma is a code coverage tool. I have been recently introduced to it. With this you can know that how much of your code was executed during the time of your test execution. Again you have to include it in your pom.xml as a dependency.

So your pom.xml dependency list may have something like this














Now you can run emma reporting using following

$mvn emma:emma
You
can expect to see an output like following

[INFO] [emma:instrument {execu
tion: default-instrument}]
[INFO] Instrumenting classes with EMMA
processing instrumentation path ...
instrumentation path processed in 266 ms
[3 class(es) instrumented, 7 resource(s) copied]
metadata merged into [E:\myWorkspace\amj-ecom\target\coverage.em] {in 31 ms}
[INFO] [resources:testResources {e
xecutio
n: default-testResources}]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platfo
rm dependent!
[INFO] skip non existing resourceDirectory E:\myWorkspace\amj-ecom\src\test\resources
[INFO] [compiler:testCompile {exe
cution: default-testCompile}]
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dep
endent!
[INFO] Compiling 1 source file to E:\myWorkspace\amj-ecom\target\test-classes
[INFO] [surefire:test {execution: default-test}]
[INFO] Surefire report directory: E:\myWorkspace\amj-ecom\target\surefire-reports

-------------------------------------------------------
T E S T S
---------------------------------------
----------------
Running mayank.anup.ecom.login.MatchingUsernamePasswordValidatorTest
EMMA: collecting runtime coverage data ...
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.172 sec

Results :

Tests run: 2, Failures: 0, Errors:
0, Skipped: 0

EMMA: runtime coverage dat
a merged into [E:\myWorkspace\amj-ecom\coverage.ec] {in 31 ms}
[WARNING] While downloading hibernate:hibernate:3.0.5
This artifact has been relocat
ed to or
g.hibernate:hibernate:3.0.5.


[INFO] [emma:emma {execution: default-cli}]
processing input files ...
2 file(s) read and merged in 47 ms
writing [xml] report to [E:\myWorkspace\amj-ecom\target\site\emma\coverage.xml] ...
writing [html] report to [E:\myWorkspace\amj-ecom\target\site\emma\index.html] ...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 24 seconds

The key thing to note is that first emma does some byte code level instrumentation with your generated main classes, then it
runs the Junit Test and finally prints the result output in html format.


Wednesday, November 24, 2010

A Sample Web Application - 1

I am trying to learn technologies using a practical approach. Right now my focus is to create a sample e-commerce web application using Java Technologies.

The technologies of focus are

1) Spring : For dependency injection
2) Struts2 : For MVC framework
3) Hibernate : For persistence
4) Maven: For build management
5) Tomcat 6 : Servlet Container
6) SVN: Source code managemnt

Since building a full scale e-com app is not in scope for small scale learning approach, i am going to take baby steps.
My first step is

Create a login funcitonality
Allow user to enter username and password. Right now the system will just say a successful validation if both username and password are same. It doesn't involve DB interaction and still able to use Spring and Struts 2 integration.

Build Instructions

Use this command to anonymously check out the latest project source code:

# Non-members may check out a read-only working copy anonymously over HTTP.

svn checkout http://amj-ecom.googlecode.com/svn/trunk/ amj-ecom-read-only

You will need a svn client for this. I am using Tortoise SVN.

To build it you just need to run ($mvn package from your command prompt). It will create a war file ecom.war in target directory. I have created a small script cleandeploy.bat for easy deployment of app to a tomcat container. You will need to edit this file to point to the correct path of tomcat dir as per your system.

Any suggestion and feedback is welcome.

I intend to add more posts as and when i add more functionality in this project.

Tuesday, October 5, 2010

Drawing with SDEdit

Today I had been assigned the task of creating sequence diagram for one of the project I am working on. As with most of the things this was first time for me.

A sequence diagram helps you in understanding flow of control from one component to another component of your software when a particular action (ex. User presses a button, or your web service receives a request, or a scheduler wakes up and starts some action) is triggered. It is the intermediate step between writing problem on a document to converting solution in a programming language (Java, C/C++ etc)

Anyways since I was new to doing this, my first thought was lets do it in Microsoft word or Powerpoint. But very soon I realized the futility of this approach. I will have spent whole day on drawing lines and blocks. Then someone suggested to use Microsoft Visio. I installed it too, but only to realize that it doesn't have capability to draw sequence diagrams.

Then I searched for tools. There are many tools available on internet but most of them are commercial. Finally I stumbled upon SDEdit. This is a java based tool and available as open source. Perfect for my needs. However understanding the working of this tool required reading the help text for 30 minutes or so. It uses commands to draw and is not as intuitive as MS Word or powerpoint. Reminds me of latex. But the end result was very beautiful. With just 10-12 commands I had drawn the sequence diagrams and created pdf out of it. It even allowed me to create pdf in landscape mode (better for viewing). Overall a very useful tool. Please share your experience and let me know if you have used other similar good open source tools for UML etc.