Saturday 13 May 2017

Epub3 conversion notes.

(1) I found this list of epub2 to epub3 conversion notes

Notes below are mine, with typical error messages returned by epubcheck validation.

(2) 'Exactly one manifest item must declare the 'nav' property (number of 'nav' items: 0).'

For Epub 3, this means you need a table of contents in an xhtml file. An ebook often comes with an html "table of contents".

You should convert it to the required format. See the example below.

Your table of contents should look something like this:

    <nav epub:type="toc" id="toc">
        <ol id="nav">
            <li><a href="chapter01.xhtml#myId">Some entry</a></li>
            <li><a href="chapter02.xhtml#myOtherId">Some other entry</a></li>
              ...
        </ol>
    </nav>

The <nav> tag is a special epub tag, so the html tag, it sits in, needs another namespace to tell it what a <nav> is:

    <html xmlns="http://www.w3.org/1999/xhtml"
          xmlns:epub="http://www.idpf.org/2007/ops"
          xml:lang="en">

Last: The <ol> tags inside your <nav> entry must not be nested (in more <ul>, or <ol> lists. One flat list only. You must use an <ol> list. <ul> not allowed.

So give this ol a style in your stylesheet. To knock out the numbers:

    ol#nav { list-style-type: none; }

In an example where "p2.xhtml" has a table of contents, .opf entry changes from:

    <item id="toc" media-type="application/xhtml+xml" 
          href="toc.xhtml" />

to:

    <item id="toc" media-type="application/xhtml+xml" 
          href="toc.xhtml" properties="nav"/>

[ PS: if you also have an svg file, add properties="svg" to that in the .opf too! ]

Pesky epub3!

Monday 24 April 2017

Locating an element to test with FlaUI

The WinForms application I'm trying to test is legacy in more ways than I'd like.

Here is FlaUI Inpect looking at a login form I want to test. I need access to 4 items. Each has an AutomationId. The ids are: textUser, textPINCode, buttonHalt, buttonLogin

These 4 controls are custom controls derived from Krypton controls. I think the Krypton controls derive from Windows Forms 2.0

Suppose I have a handle on the top level window ("FormSplashScreen"). What is the XPath to get one of the 4 I want (say textUser)?

Thursday 6 April 2017

AOP - Aspect Oriented Programming

Aspect-oriented programming was first described 20 years ago due to work of a team led by legendary programmer Gregor Kiczales [who also co-authored the book "The Art of the Metaobject Protocol" ]

What is it?

AOP aims to eliminate the noise of cross-cutting concerns, CCC, by putting them all in one place while still allowing the code previously "tangled" up with CCC to work just as before. The business logic is clearer, easier to read and maintain.

AOP concepts

  • cross-cutting concern, CCC: Is code which applies all over the place and often relates to getting an application to work rather than to any business concern. It cuts across an application. e.g. authentication, logging, exception handling, caching data, wrapping a transaction around something, auditing, ...
  • join point - a place in code where it can be 'cut', joined to, or intercepted. e.g. just before I call svc.SaveName()
  • Pointcut - a set of join points. e.g. just before any SaveName() method in project UI is called.
  • advice - some code to be applied by AOP
  • aspect - a combination of Pointcuts with advice
  • tangling - when CCC(s) are mixed with business or core logic like spaghetti such that the core logic is confusing to read.
  • scattering - having CCCs in multiple methods and classes
  • weaving - how AOP applies aspects to core logic.

Potential applications for ApoG

  • Authentication and Authorization : by putting this all together in one place the problem of security is not confused with other business logic.
  • Data caching
  • Exception handling - hopefully including all unhandled exceptions. ApoG currently has 991 exceptions.
  • Logging - There are over 2000 of these
  • Transaction wrap-around e.g. to save a unit of work. ApoG currently does not have unit of work transactions but these will be needed in future.
  • Auditing? - i.e. The process of saving PDF files and entries to the database can be put in one place.

Advantages

  • Cleaner code
  • DRY - It applies Don't repeat yourself. It reduces code duplication
  • SRP - It applies the Single Responsibility Principle. Ensures a method or class does only one job.
  • Readability is improved - because one can read the core logic without being distracted by the CCCs
  • Maintenance is easier - because code relating to a CCC is in only one place it is easier to update. Because core logic is cleaner and uncluttered by tangential concerns it is easier to change just the core logic without interfering with anything else.
  • Money is no object because every AOP tool but one is free. Dozens of AOP tools have been written.

Disadvantages

  • ????

Software

Top 20 AOP tools

Interception, code. License: MIT OSS

NConcern: Is a relative newcomer. License: OSS

PostSharp: This has been the main .net AOP package since it arrived on the scene. License: Commercial software. Licenses are up to £449 per developer for a lifetime license. Limited licences are less. Not so expensive. Consider: If AOP improves productivity by 5%, the saving is at least £2500 per year, when one considers the average annual cost of a programmer is certainly over £50k/year. PostSharp Express is free but limited.

Training:

More articles:

AOP with the RealProxy Class | Principles of AOP, from 2015

Examples

Also see book listed above: AOP in .net. Although it may look like many AOP packages are not well documented, they often use similar implementation patterns. Like dependency injection, once one understands the principle, changing tools is relatively easy.

Thursday 9 February 2017

F-sharp books.

TitleLevelAuthorsPublisherDatePagesComment
Learn F# (MEAP)IntroIsaac AbrahamManningApr-2017400
Real-World Functional Programming with examples in F# and C#Tomas Petricek with Jon SkeetManningDec-2009560
Beginning F# 4.0Robert Pickering, Kit EasonApress2016309
Friendly F# (Fun with game programming)Costantini, Giulia & Maggiore, GiuseppeO'ReillyAug-2011191
F# SuccinctlyFreeRobert PickeringSyncfu-sion201296Free
Analyzing and Visualizing Data with F#Tomas PetricekO'ReillyOct-201547Free, from publisher
FSharp Specification 4.0Fsharp FoundationFsharp Founda-tion365Free, Not really a book but can be published as such
F# Web ProgrammingCommunity for F#GitBookFree. Not really a book because it's just a set of hints!
F# Survival GuideJohn Puopolo, Sandy SquiresCTO Corner2012171Free.
Suave Music Store example77
The Book of F#Interm-ediateDave FancherNo Starch PressMar-2014312
Professional F# 2.0Ted Neward Aaron, C. Erickson, Talbott Crowell, Richard MinerichWrox2011434
Programming F-sharp 3.0, 2eChris SmithO'ReillyOct-2012476
Testing with F#Mikael LundinPacktFeb-2015286
F# for DevelopersTao LiuMicro-soft2013619
Windows Phone 7.5 Application Development with F#Web / mobileLohith G.N.PacktApr-2013138
Building Web, Cloud, and Mobile Solutions with F#Daniel MohlO'ReillyNov-2012176
F# Applied, A practical guide to Web dev in F# using SuaveTamizhvendan S201696link
Expert F# 4.0ExpertDon Syme, Adam Granicz & Antonio CisterninoApress20155824 editions of this book
F# High PerformanceEriawan KusumawardhonoPacktJan-2017338
Mastering F#Alfonso García-Caro Núñez, Suhaib FahadPacktNov-2016264
F# 4.0 Design PatternsGene BelitskiPacktNov-2016318
F# for Quantitative FinanceJohan AstborgPacktDec-2013286
F# 4.0 Programming CookbookKevin AshtonPacktAug-2017371
F# Deep DivesEdited by Tomas Petricek, Phillip TrelfordManningDec-2014372
F# for Machine Learning EssentialsMachine LearningSudipta MukherjeePacktFeb-2016194
Machine Learning Projects for .NET DevelopersMathias BrandewinderApress2015300
Learning F# Functional Data Structures and AlgorithmsCompu-ter sciencyAdnan MasoodPacktJun-2015206
Fsharp for ScientistsJon D HarropWiley2008334
F# for Technical ComputingJon D HarropFlying frog2010279
Programming Language ConceptsPeter SestoftSpringer2012278
Functional Programming Using F#Michael R. Hansen, Hans Rischel CUPMay-2013372

Of interest. Maybe watch/read