I need to know what the users of my library need, but I don't have any users yet. What should I do?

When you are defining who your target audience is, it can be rather difficult to decide who your users will be. If you've been building capabilities in a certain domain for a while and can solve specific problems with those capabilities, then you will likely want to look for users that may have those problems. You may even end up creating personas or prototypical users who have the problems that your library might solve.

Once you've established those prototypical users, you should try to find them in person and confirm your assumptions. You do not want to be building features that they don't need. In the event you cannot get access to any real users, you can still make use of user proxies. User proxies are people that can somewhat act as the true end-users, but are not the true end-users, so that you have to be careful about what they tell you they need since it is likely to be biased by their actual position. Some potential user proxies are:

  • The users' manager
  • Salespeople
  • Domain experts
  • Former users
  • Customers
  • Trainer and technical support
  • Business or system analysts

In User Stories Applied: For Agile Software Development, Mike Cohn suggests to use more than one user proxy to mitigate the bias from any specific user proxy. Make sure that the user proxies are of different types. This technique is comparable to using ensembling in machine learning.

10 Feb 2020

AST in python

History / Edit / PDF / EPUB / BIB / 1 min read (~193 words)
Problems Software development Python

I want to analyze a python script to extract something from it. How do I do that?

Python has an abstract syntax tree like most programming language.

You can use the ast module to parse a string that contains the code you want to analyze.

A simple example is as follow. It will read a file defined in the file variable, use ast to parse it, returning a tree that can then be traversed using the visitor pattern. Defining visitors lets you separate the responsibility of each of them, making the code that analyzes code easier to understand.

import ast

class ClassVisitor(ast.NodeVisitor):
    def visit_ClassDef(self, node):
        # Do some logic specific to classes
        self.generic_visit(node)

class FunctionVisitor(ast.NodeVisitor):
    def visit_FunctionDef(self, node):
        # Do some logic specific to functions
        self.generic_visit(node)

visitors = [
    ClassVisitor(),
    FunctionVisitor()
]

with open(file, "r") as f:
    code = f.read()

    tree = ast.parse(code)

    for visitor in visitors:
        visitor.visit(tree)