Wednesday, December 8, 2010

UTF-8

Having some issues with UTF-8 files with illegal characters. Trying to make a filter, or at least a problem reporter. Good info by dwheeler.

Sunday, December 5, 2010

Using Scomp

I'm working on a project that deals with XMPP information. I'm using xmlbeans scomp to compile xsd files into java classes. I got the source code to work, but scomp failed to generate a jar file. I got the error described by Three Wise Men and Celinio Fernandes. I'm working on Windows XP.

With the scomp src I built an Eclipse project and could build against it, but got this run time exception:
ClassNotFoundException : Cannot load SchemaTypeSystem. Unable to load class with name schemaorg_apache_xmlbeans.system.s68C41DB812F52C975439BA10FE4FEE54
In trying to solve it I learned to use javac from the command line (I have only used the Eclipse JDE until now.) I installed Ant (I thought there was a dependency) and learned to use. I learned how to produce a jar in Eclipse. None of these solved the problem.

Three Wise Men set me on the right track. The problem is a space in the javac path. Three Wise Men fix it by using scomp's -compiler option. However, for me, scomp still choked on the space. So I found out about junction (see Wikipedia). I used junction to make Program-Files link to Program Files (skip the md step in the junction example). Put the hypen in my JAVA_HOME and path. Still scomp failed to make jar. Finally used compiler option with hypen and it worked. Added jar to my build path in Eclipse and finally my project ran correctly.

Whew! Lotta work just for that.

Wednesday, December 1, 2010

Lots!

Learned this morning that Python compiles when a module is called up. However, Apache, default Windows settings with wsgi, seems to cache Python code. Need to stop and start server after every Python change.

Learned more than I can describe at new job today. Much more to pickup. Need to shelve home Django & Python stuff for a while. Two projects at work, lower priority uses Dj & Py, so may be back to it soon.

Tuesday, November 30, 2010

Django install on Apache server

Django doc on using with wsgi server.

Learned that the base wsgi file (django.wsgi) needs to be in a legal server path. On my machine that's c:/xampp/htdocs. Otherwise get 403 error. However, the wsgi file can refer to projects anywhere on computer. The project does need to be on the path, as the doc says (and shows how to do. However, the setting of DJANGO_SETTINGS_MODULE is a little misleading. I added my project to the path (c:/xampp/django/avppng). Then DJANGO_SETTINGS_MODULE = 'settings' because it is relative to the path. The doc shows setting path to django (c:/xampp/django) and DJANGO_SETTINGS_MODULE='avppng.settings'. But this makes some relative paths in the project not work.

Python errors produce 500 errors. Look at Apache error log file c:/xampp/apache/logs/error.log to see Python errors. The doc mentioned setting LogLevel info in httpd.conf, but the default warn setting worked fine for me. Tried to use sys.stderr.write to write to log file, but didn't work.

Now I see something disturbing. I just saw an error that my administration module couldn't be found in avppng.urls. So in wsgi file I changed the path to c:/xampp/django/avppng/ and DJANGO_SETTINGS_MODULE to settings. Shut down, made a change. Then it told me a django py couldn't find avppng.urls. So I changed path back to c:/xampp/django and DJANGO_SETTINGS_MODULE to avppng.settings and it worked! How can one way work then not and visa versa?? (Slash at end of path doesn't seem to make a difference.)


Django tag cloud

Tag clouds for Django. Stackoverflow post has info. Logarithmic tag algorithm. Napes intro to using tag clouds. Django-tagging package.

Django social authorization

Post about package to allow login through social media (Facebook, Google, etc) ids.

Sunday, November 28, 2010

Django lookups

Django or lookups.

Django list posts

QueryDict is used to handle lists (as dictionaries) in GET/POST forms.

Question: How is QueryDict set? Documentation just refers to it: q = QueryDict('a=1'). How does it know where to get info?

Django foo never uses QueryDict directly:
1def handle(request):
2 if request.method == 'POST':
3 artists = request.POST.getlist('artists') # now artists is a list of [1,2,3]


Really? I guess so. Appendix H says GET and POST are "dictionary-like" objects. Then how does this code work?
cur_cat = int(request.POST['CategorySelect'])

Does it convert the first key into an integer? No, that fails.

C:\xampp\django\avppng>python
Python 2.7 (r27:82525, Jul 4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> dict = {1:'a', 2:'b'}
>>> dict
{1: 'a', 2: 'b'}
>>> int(dict)
Traceback (most recent call last):
File "", line 1, in
TypeError: int() argument must be a string or a number, not 'dict'
>>>

So request.POST['CategorySelect'] must not be a dictionary. In fact, if post is a dictionary, then request.POST['CategorySelect'] is a value from a dictionary.

>>> dict3 = {'cs':'1', 'junk':'2'}
>>> dict3
{'cs': '1', 'junk': '2'}
>>> int(dict3['cs'])
1

So POST is a dictionary of item name vs. item value? D'oh! Now the QueryDict doc makes more sense: "QueryDict is a dictionary-like class customized to deal with multiple values for the same key." Django foo's example above makes more sense too. Finally, Appendix H has a full example at the end that makes this all clear!


Saturday, November 27, 2010

Design Patterns, Wikipedia

Reading Design Patterns on Wikipedia. Started in architecture, spread to computer.

Seminal book Design Patterns: Elements of Reusable Object-Oriented Software. Written by Gang of Four (GoF). Uses Unified Modeling Language (UML), which supersedes the Booch Method.

OK, regressing a lot. Need to learn UML. Overview of Book is interesting. Maybe get book to see details.

Enough for today.

Friday, November 26, 2010

Regression Testing

More on regression testing.

My brother discussed with me idea of two sets of developers: one writes app, one writes tests to same spec. Referring perhaps to the ISO 90003 standard.

See software to aid testing like HP Quality Center, Seapine QA Wizard, Borland Silktest, VectorCAST.


Design Pattern Intro


From Schmidt's framework overview. Frameworks provide developers modularity, reusability, extensibility, and inversion of control. Early GUIs MacApp and Interviews. MFC now a standard. Object Request Broker (ORB) facilitate comm btwn local and remote object

Types
  • System, like OS and comm networks.
  • Middle-ware, like ORB, msg-oriented middle-ware, transactional databases.
  • Enterprise, broad app domains like telecomm, avionics, manufacturing, financial engineering.
Implementation types
  • Whitebox. Extend FW objects.
  • Blackbox. Use FW defined interfaces.

C0mpare framworks with
  • Patterns. Frameworks more concrete.
  • Class libraries. CL more generic & passive. FW more complete solution.
  • Components. Objects that can plug together into app. Seem to me halfway betwn CL and FW.

Android Library and Admob

I changed my Remata application to use a library. I keep most of the code in the library, then can make small projects for application variants. I am having problems getting Admob layout code to work.

First, I was a little fuzzy on including an external jar. I think I should be able to just include it in the library, but I seem to also have to include it in the main application. Is this because libraries are just build constructs, so the library inclusion of a jar is ignored when the main app is built? Turns out Android doc addresses this here: "You can develop a library project that itself includes a JAR library, however you need to manually edit the dependent application project's build path and add a path to the JAR file."

Meanwhile, back to my layout problem. Here is my Admob layout code.

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res/com.rellimsoft.android.remata.base"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">

<com.admob.android.ads.AdView
android:id="@+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
myapp:backgroundColor="#000000"
myapp:primaryTextColor="#FFFFFF"
myapp:secondaryTextColor="#CCCCCC"
/>
</LinearLayout>

I get this error: "No resource identifier found for attribute 'backgroundColor' in package 'com.rellimsoft.android.remata.base'". Same for all the "myapp" attributes. I examined this and wonder if referring to an apk in a library is a problem since libraries don't generate apk's (xmlns:myapp="http://schemas.android.com/apk/res/com.rellimsoft.android.remata.base"" ).

Turns out it's not an Admob problem, but an Eclipse problem when generally referring to attributes in a library (see this post on Stackoverflow). Sounds like it can't really be done cleanly in Eclipse.

Ideas.
  • Is the apk a problem? Prob not. Comment on Stackoverflow seem like it works if built properly, more of an Eclipse problem.
  • Refer to dependent app in library. Hate this!! Can reduce hit by at least having dependent app interface to get info, but still needed in resource layout file.
  • Conflate view in Java code. Use interface that main app can implement. Need to check if this can be done. Still not great, but maybe can avoid the absolutely wrong library referring to dependent code.
---------------------
Solved it!

First, helpful start on creating views in UI. Turns out I don't even need to conflate view in code or parent code. Just add attributes in Java. Here is my new layout, minus the offending attributes.


<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res/com.rellimsoft.android.remata.base"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">

<com.admob.android.ads.AdView
android:id="@+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>

Here is the corresponding Java code in my onCreate method (mAddView defined as class global).


private AdView mAdView = null;
...
mAdView = (AdView)findViewById(R.id.ad);
mAdView.setBackgroundColor(0x000000);
mAdView.setPrimaryTextColor(0xFFFFFF);
mAdView.setSecondaryTextColor(0xCCCCCC);

This methodology is a simple, well-structured solution for Admob. It probably is good for many cases. It will be bad if there are huge layouts that need to be included in code, since doing so is easier in xml layouts. However, the only problem is dealing with attributes defined in the current namespace, I wouldn't think that would affect layouts over a large scale. This solution also allows getting rid of data in attr.xml.

Regression

Topic of regression testing came up. I take it to mean testing software against "regressions". That is, creating automated tests for every new feature or bug fix. These tests are then run against any future change to make sure the feature continues to work and that bugs once fixed never occur again. Having a previously working feature break or a bug re-occur is called a "regression" -- thus the name of the test. I believe I am supported in my definition, for example by Wikipedia and Webopedia.

I was in a recent discussion where it was taken to mean more than that. Proper hierarchical ordering of tests to ensure only the necessary tests are run was mentioned. I'm familiar with selecting only affected tests. But it sounds like there's more to it than this. I need to learn more here.

I mentioned it to my wife and she showed me Super Crunchers (Ian Ayres, Bantam, 2007). Ayres mentions regressions (defined pg. 23). He uses it to mean formulas derived from statistical data that predict future results. I learned something! I tend to call this "correlation" because the mathematics behind Ayres regression formulas is what I call correlation processing. I've used it in a signal processing context, but I believe it is similar to what Ayres is talking about. I never knew before that when statisticians referred to "regressions" this is what they were referring to.

Is there software testing, say for performance, that uses correlation processing to produce a "regression" that explains what is happening? Like which factors most contribute to performance hits? Or am I just being silly? Need to learn more.

Learning New Things

I'm learning lots of new stuff. I'm a life-long learner. I've read many books, especially about physics, math and astronomy. I work as a software engineer which involves constant learning. Recently I have been learning at a higher rate and wanted to record some of what I've learned. Here it is!